mirror of
https://github.com/clap-rs/clap
synced 2024-11-13 08:07:11 +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 "${prev}" in
|
||||||
|
|
||||||
--case)
|
--case)
|
||||||
COMPREPLY=("<case>")
|
COMPREPLY=($(compgen -f ${cur}))
|
||||||
return 0
|
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'
|
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))]
|
#[allow(dead_code)]
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os="windows"))]
|
||||||
static POWERSHELL: &'static str = r#"
|
static POWERSHELL: &'static str = r#"
|
||||||
@('myapp', './myapp') | %{
|
@('myapp', './myapp') | %{
|
||||||
Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
|
Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
|
||||||
|
@ -241,8 +241,8 @@ static POWERSHELL: &'static str = r#"
|
||||||
}
|
}
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
#[cfg_attr(target_os = "windows", allow(dead_code))]
|
#[allow(dead_code)]
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os="windows")]
|
||||||
static POWERSHELL: &'static str = r#"
|
static POWERSHELL: &'static str = r#"
|
||||||
@('myapp', './myapp', 'myapp.exe', '.\myapp', '.\myapp.exe', './myapp.exe') | %{
|
@('myapp', './myapp', 'myapp.exe', '.\myapp', '.\myapp.exe', './myapp.exe') | %{
|
||||||
Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
|
Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
|
||||||
|
@ -282,8 +282,8 @@ static POWERSHELL: &'static str = r#"
|
||||||
}
|
}
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
#[cfg_attr(not(target_os = "windows"), allow(dead_code))]
|
#[allow(dead_code)]
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os="windows"))]
|
||||||
static POWERSHELL_SPECIAL_CMDS: &'static str = r#"
|
static POWERSHELL_SPECIAL_CMDS: &'static str = r#"
|
||||||
@('my_app', './my_app') | %{
|
@('my_app', './my_app') | %{
|
||||||
Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
|
Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
|
||||||
|
@ -343,8 +343,8 @@ static POWERSHELL_SPECIAL_CMDS: &'static str = r#"
|
||||||
}
|
}
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
#[cfg_attr(target_os = "windows", allow(dead_code))]
|
#[allow(dead_code)]
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os="windows")]
|
||||||
static POWERSHELL_SPECIAL_CMDS: &'static str = r#"
|
static POWERSHELL_SPECIAL_CMDS: &'static str = r#"
|
||||||
@('my_app', './my_app', 'my_app.exe', '.\my_app', '.\my_app.exe', './my_app.exe') | %{
|
@('my_app', './my_app', 'my_app.exe', '.\my_app', '.\my_app.exe', './my_app.exe') | %{
|
||||||
Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
|
Register-ArgumentCompleter -Native -CommandName $_ -ScriptBlock {
|
||||||
|
@ -621,7 +621,7 @@ static BASH_SPECIAL_CMDS: &'static str = r#"_my_app() {
|
||||||
case "${prev}" in
|
case "${prev}" in
|
||||||
|
|
||||||
--config)
|
--config)
|
||||||
COMPREPLY=("<config>")
|
COMPREPLY=($(compgen -f ${cur}))
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
@ -640,7 +640,7 @@ static BASH_SPECIAL_CMDS: &'static str = r#"_my_app() {
|
||||||
case "${prev}" in
|
case "${prev}" in
|
||||||
|
|
||||||
--case)
|
--case)
|
||||||
COMPREPLY=("<case>")
|
COMPREPLY=($(compgen -f ${cur}))
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
@ -742,63 +742,45 @@ fn build_app_with_name(s: &'static str) -> App<'static, 'static> {
|
||||||
App::new(s)
|
App::new(s)
|
||||||
.about("Tests completions")
|
.about("Tests completions")
|
||||||
.arg(Arg::with_name("file").help("some input file"))
|
.arg(Arg::with_name("file").help("some input file"))
|
||||||
.subcommand(
|
.subcommand(SubCommand::with_name("test")
|
||||||
SubCommand::with_name("test").about("tests things").arg(
|
.about("tests things")
|
||||||
Arg::with_name("case")
|
.arg(Arg::with_name("case")
|
||||||
.long("case")
|
.long("case")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.help("the case to test"),
|
.help("the case to test")))
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_app_special_commands() -> App<'static, 'static> {
|
fn build_app_special_commands() -> App<'static, 'static> {
|
||||||
build_app_with_name("my_app")
|
build_app_with_name("my_app")
|
||||||
.subcommand(
|
.subcommand(SubCommand::with_name("some_cmd")
|
||||||
SubCommand::with_name("some_cmd")
|
.about("tests other things")
|
||||||
.about("tests other things")
|
.arg(Arg::with_name("config")
|
||||||
.arg(
|
.long("--config")
|
||||||
Arg::with_name("config")
|
.takes_value(true)
|
||||||
.long("--config")
|
.help("the other case to test")))
|
||||||
.takes_value(true)
|
|
||||||
.help("the other case to test"),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.subcommand(SubCommand::with_name("some-cmd-with-hypens"))
|
.subcommand(SubCommand::with_name("some-cmd-with-hypens"))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_app_special_help() -> App<'static, 'static> {
|
fn build_app_special_help() -> App<'static, 'static> {
|
||||||
App::new("my_app")
|
App::new("my_app")
|
||||||
.arg(
|
.arg(Arg::with_name("single-quotes")
|
||||||
Arg::with_name("single-quotes")
|
.long("single-quotes")
|
||||||
.long("single-quotes")
|
.help("Can be 'always', 'auto', or 'never'"))
|
||||||
.help("Can be 'always', 'auto', or 'never'"),
|
.arg(Arg::with_name("double-quotes")
|
||||||
)
|
.long("double-quotes")
|
||||||
.arg(
|
.help("Can be \"always\", \"auto\", or \"never\""))
|
||||||
Arg::with_name("double-quotes")
|
.arg(Arg::with_name("backticks")
|
||||||
.long("double-quotes")
|
.long("backticks")
|
||||||
.help("Can be \"always\", \"auto\", or \"never\""),
|
.help("For more information see `echo test`"))
|
||||||
)
|
.arg(Arg::with_name("backslash")
|
||||||
.arg(
|
.long("backslash")
|
||||||
Arg::with_name("backticks")
|
.help("Avoid '\\n'"))
|
||||||
.long("backticks")
|
.arg(Arg::with_name("brackets")
|
||||||
.help("For more information see `echo test`"),
|
.long("brackets")
|
||||||
)
|
.help("List packages [filter]"))
|
||||||
.arg(
|
.arg(Arg::with_name("expansions")
|
||||||
Arg::with_name("backslash")
|
.long("expansions")
|
||||||
.long("backslash")
|
.help("Execute the shell command with $SHELL"))
|
||||||
.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]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue