-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: completions for bins with dashes
Fixes #163
- Loading branch information
Showing
3 changed files
with
16 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,11 @@ use heck::ToSnakeCase; | |
|
||
pub fn complete_bash(opts: &CompleteOptions) -> String { | ||
let bin = &opts.bin; | ||
let bin_snake = bin.to_snake_case(); | ||
let spec_variable = if let Some(cache_key) = &opts.cache_key { | ||
format!("_usage_spec_{bin}_{}", cache_key.to_snake_case()) | ||
format!("_usage_spec_{bin_snake}_{}", cache_key.to_snake_case()) | ||
} else { | ||
format!("_usage_spec_{bin}") | ||
format!("_usage_spec_{bin_snake}") | ||
}; | ||
let mut out = vec![format!( | ||
r#"_{bin}() {{ | ||
|
@@ -46,7 +47,7 @@ __USAGE_EOF__"#, | |
return 0 | ||
}} | ||
shopt -u hostcomplete && complete -o nospace -o bashdefault -o nosort -F _{bin} {bin} | ||
shopt -u hostcomplete && complete -o nospace -o bashdefault -o nosort -F _{bin_snake} {bin} | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jdx
Author
Owner
|
||
# vim: noet ci pi sts=0 sw=4 ts=4 ft=sh | ||
"# | ||
)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This isn't necessary. But if you want to keep it, then line 13 needs to become
otherwise we get