Skip to content

Commit

Permalink
tests(Bash Completions): updates the bash completions to the new file…
Browse files Browse the repository at this point in the history
… completion fallback
  • Loading branch information
kbknapp committed Feb 13, 2018
1 parent 79a2104 commit cdfdbff
Showing 1 changed file with 41 additions and 59 deletions.
100 changes: 41 additions & 59 deletions tests/completions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static BASH: &'static str = r#"_myapp() {
case "${prev}" in
--case)
COMPREPLY=("<case>")
COMPREPLY=($(compgen -f ${cur}))
return 0
;;
*)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
;;
*)
Expand All @@ -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
;;
*)
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit cdfdbff

Please sign in to comment.