-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Generate shell completions with clap during build #327
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thank you very much!
We should also ship these files with each release (see e.g. https://github.com/sharkdp/fd/blob/56b6389dac945df313ce54072fcc01b91211a76c/ci/before_deploy.bash#L41-L43)
Cargo.toml
Outdated
@@ -43,3 +44,6 @@ features = [] | |||
|
|||
[dev-dependencies] | |||
tempdir = "0.3" | |||
|
|||
[build-dependencies] | |||
clap = "2.32.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use "2.32"
to be consistent with the dependency above.
build.rs
Outdated
|
||
fn main() { | ||
|
||
let outdir = match std::env::var_os("OUT_DIR") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use the same mechanism as in fd
here:
let outdir = std::env::var_os("SHELL_COMPLETIONS_DIR").or(std::env::var_os("OUT_DIR"));
See sharkdp/fd#121
It would also require us to use fs::create_dir_all
:
sharkdp/fd@3104729
…ild.rs and fixed dependency version
@@ -38,6 +38,11 @@ pack() { | |||
cp LICENSE-MIT "$tempdir/$package_name" | |||
cp LICENSE-APACHE "$tempdir/$package_name" | |||
|
|||
# various autocomplete | |||
cp target/"$TARGET"/release/build/"$PROJECT_NAME"-*/out/"$PROJECT_NAME".bash "$tempdir/$package_name/autocomplete/${PROJECT_NAME}.bash-completion" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to make sure that the target directory exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it would be great to do this for Windows deployments as well (in the before_deploy.ps1
script). I think we don't need a subfolder in case of the Windows archive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with how it should work on Windows.
Should it be something like this ?
Copy-Item "$SRC_DIR\target\release\build\bat-*\out\_bat.ps1" '.\autocomplete'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess just
Copy-Item $SRC_DIR\target\release\build\bat-*\out\_bat.ps1 '.\'
Travis is currently failing due to some formatting issues. You can |
is this the same as running
Uhm probably not. |
Hm, I'm not sure, but there might very well be a change in the format between this and rustfmt-nightly (which we currently use to enforce the style guide). This is unfortunate, but apparently there will be a 1.0 release soon which should stabilize the format. |
This reverts commit 5c1b3de.
Thank you very much!! |
Auto-generate shell-completion files via clap #115