mirror of
https://github.com/clap-rs/clap
synced 2024-11-10 23:04:23 +00:00
tests(Bash Completions): updates the bash completions to the new file completion fallback
This commit is contained in:
parent
79a210472c
commit
cdfdbfffb5
1 changed files with 41 additions and 59 deletions
|
@ -71,7 +71,7 @@ static BASH: &'static str = r#"_myapp() {
|
|||
case "${prev}" in
|
||||
|
||||
--case)
|
||||
COMPREPLY=("<case>")
|
||||
COMPREPLY=($(compgen -f ${cur}))
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
|
@ -189,8 +189,8 @@ complete -c myapp -n "__fish_using_command myapp help" -s h -l help -d 'Prints h
|
|||
complete -c myapp -n "__fish_using_command myapp help" -s V -l version -d 'Prints version information'
|
||||
"#;
|
||||
|
||||
#[cfg_attr(not(target_os = "windows"), allow(dead_code))]
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
#[allow(dead_code)]
|
||||
#[cfg(not(target_os="windows"))]
|
||||
static POWERSHELL: &'static str = r#"
|
||||
@('myapp', './myapp') | %{
|
||||
Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
|
||||
|
@ -241,8 +241,8 @@ static POWERSHELL: &'static str = r#"
|
|||
}
|
||||
"#;
|
||||
|
||||
#[cfg_attr(target_os = "windows", allow(dead_code))]
|
||||
#[cfg(target_os = "windows")]
|
||||
#[allow(dead_code)]
|
||||
#[cfg(target_os="windows")]
|
||||
static POWERSHELL: &'static str = r#"
|
||||
@('myapp', './myapp', 'myapp.exe', '.\myapp', '.\myapp.exe', './myapp.exe') | %{
|
||||
Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
|
||||
|
@ -282,8 +282,8 @@ static POWERSHELL: &'static str = r#"
|
|||
}
|
||||
"#;
|
||||
|
||||
#[cfg_attr(not(target_os = "windows"), allow(dead_code))]
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
#[allow(dead_code)]
|
||||
#[cfg(not(target_os="windows"))]
|
||||
static POWERSHELL_SPECIAL_CMDS: &'static str = r#"
|
||||
@('my_app', './my_app') | %{
|
||||
Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
|
||||
|
@ -343,8 +343,8 @@ static POWERSHELL_SPECIAL_CMDS: &'static str = r#"
|
|||
}
|
||||
"#;
|
||||
|
||||
#[cfg_attr(target_os = "windows", allow(dead_code))]
|
||||
#[cfg(target_os = "windows")]
|
||||
#[allow(dead_code)]
|
||||
#[cfg(target_os="windows")]
|
||||
static POWERSHELL_SPECIAL_CMDS: &'static str = r#"
|
||||
@('my_app', './my_app', 'my_app.exe', '.\my_app', '.\my_app.exe', './my_app.exe') | %{
|
||||
Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
|
||||
|
@ -621,7 +621,7 @@ static BASH_SPECIAL_CMDS: &'static str = r#"_my_app() {
|
|||
case "${prev}" in
|
||||
|
||||
--config)
|
||||
COMPREPLY=("<config>")
|
||||
COMPREPLY=($(compgen -f ${cur}))
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
|
@ -640,7 +640,7 @@ static BASH_SPECIAL_CMDS: &'static str = r#"_my_app() {
|
|||
case "${prev}" in
|
||||
|
||||
--case)
|
||||
COMPREPLY=("<case>")
|
||||
COMPREPLY=($(compgen -f ${cur}))
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
|
@ -742,63 +742,45 @@ fn build_app_with_name(s: &'static str) -> App<'static, 'static> {
|
|||
App::new(s)
|
||||
.about("Tests completions")
|
||||
.arg(Arg::with_name("file").help("some input file"))
|
||||
.subcommand(
|
||||
SubCommand::with_name("test").about("tests things").arg(
|
||||
Arg::with_name("case")
|
||||
.long("case")
|
||||
.takes_value(true)
|
||||
.help("the case to test"),
|
||||
),
|
||||
)
|
||||
.subcommand(SubCommand::with_name("test")
|
||||
.about("tests things")
|
||||
.arg(Arg::with_name("case")
|
||||
.long("case")
|
||||
.takes_value(true)
|
||||
.help("the case to test")))
|
||||
}
|
||||
|
||||
fn build_app_special_commands() -> App<'static, 'static> {
|
||||
build_app_with_name("my_app")
|
||||
.subcommand(
|
||||
SubCommand::with_name("some_cmd")
|
||||
.about("tests other things")
|
||||
.arg(
|
||||
Arg::with_name("config")
|
||||
.long("--config")
|
||||
.takes_value(true)
|
||||
.help("the other case to test"),
|
||||
),
|
||||
)
|
||||
.subcommand(SubCommand::with_name("some_cmd")
|
||||
.about("tests other things")
|
||||
.arg(Arg::with_name("config")
|
||||
.long("--config")
|
||||
.takes_value(true)
|
||||
.help("the other case to test")))
|
||||
.subcommand(SubCommand::with_name("some-cmd-with-hypens"))
|
||||
}
|
||||
|
||||
fn build_app_special_help() -> App<'static, 'static> {
|
||||
App::new("my_app")
|
||||
.arg(
|
||||
Arg::with_name("single-quotes")
|
||||
.long("single-quotes")
|
||||
.help("Can be 'always', 'auto', or 'never'"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("double-quotes")
|
||||
.long("double-quotes")
|
||||
.help("Can be \"always\", \"auto\", or \"never\""),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("backticks")
|
||||
.long("backticks")
|
||||
.help("For more information see `echo test`"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("backslash")
|
||||
.long("backslash")
|
||||
.help("Avoid '\\n'"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("brackets")
|
||||
.long("brackets")
|
||||
.help("List packages [filter]"),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("expansions")
|
||||
.long("expansions")
|
||||
.help("Execute the shell command with $SHELL"),
|
||||
)
|
||||
.arg(Arg::with_name("single-quotes")
|
||||
.long("single-quotes")
|
||||
.help("Can be 'always', 'auto', or 'never'"))
|
||||
.arg(Arg::with_name("double-quotes")
|
||||
.long("double-quotes")
|
||||
.help("Can be \"always\", \"auto\", or \"never\""))
|
||||
.arg(Arg::with_name("backticks")
|
||||
.long("backticks")
|
||||
.help("For more information see `echo test`"))
|
||||
.arg(Arg::with_name("backslash")
|
||||
.long("backslash")
|
||||
.help("Avoid '\\n'"))
|
||||
.arg(Arg::with_name("brackets")
|
||||
.long("brackets")
|
||||
.help("List packages [filter]"))
|
||||
.arg(Arg::with_name("expansions")
|
||||
.long("expansions")
|
||||
.help("Execute the shell command with $SHELL"))
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue