Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add shell completions #87

Merged
merged 8 commits into from
Jul 23, 2024

Conversation

rsrohitsingh682
Copy link
Contributor

Add Shell Completions in nixci using clap_complete similar to how we have in ripgrep

Screenshot 2024-07-18 at 9 50 57 PM

src/cli.rs Outdated Show resolved Hide resolved
src/completion.rs Outdated Show resolved Hide resolved
Copy link
Owner

@srid srid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

src/lib.rs Show resolved Hide resolved
@srid
Copy link
Owner

srid commented Jul 18, 2024

One more thing: how do I actually use this?

Specifically in https://github.com/juspay/nix-dev-home ?

@srid
Copy link
Owner

srid commented Jul 18, 2024

One more thing: how do I actually use this?

Okay, I tested this PR in https://github.com/srid/nixos-config - but I don't see any completions. I typed nixci bu and then TAB. Nothing happens.

flake.nix Outdated Show resolved Hide resolved
@rsrohitsingh682
Copy link
Contributor Author

One more thing: how do I actually use this?

Okay, I tested this PR in https://github.com/srid/nixos-config - but I don't see any completions. I typed nixci bu and then TAB. Nothing happens.

When I manually source the completion script by generating it then it works.

@srid
Copy link
Owner

srid commented Jul 19, 2024

When I manually source the completion script by generating it then it works.

When I add ripgrep to https://github.com/juspay/nix-dev-home (or my nixos-config), autocompletion works.

When I add nixci (from this PR) to https://github.com/juspay/nix-dev-home (or my nixos-config), autocompletion does not work.

What can we do in nixci to make it work just like ripgrep, without the user needing to do manual setup (like manual sourcing of the completion script)?

Copy link
Owner

@srid srid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it to work! Just needs these changes before merge.

image image

Cargo.toml Outdated
@@ -33,6 +33,8 @@ nix_rs = { version = "0.5.0", features = ["clap"] }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
tracing = "0.1.37"
nix_health = "0.4.1"
clap_complete = "4.4.0"
async-trait = "0.1.73"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dependency is no longer used.

src/cli.rs Outdated
command::NixCmd,
config::NixConfig,
flake::{system::System, url::FlakeUrl},
};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undo this re-arrangement of imports as it is not necessary for this PR.

@srid srid changed the title feat(nixci): add shell completions feat: add shell completions Jul 23, 2024
@srid srid merged commit 1b2caf3 into srid:master Jul 23, 2024
4 checks passed
@rsrohitsingh682 rsrohitsingh682 deleted the add-shell-autocompletion branch July 23, 2024 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants