2022-03-07 20:43:51 +00:00
|
|
|
Following are tests for the interop examples in this directory.
|
|
|
|
|
|
|
|
## Augment Args
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ interop_augment_args
|
|
|
|
Value of built: false
|
|
|
|
Value of derived via ArgMatches: false
|
|
|
|
Value of derived: DerivedArgs {
|
|
|
|
derived: false,
|
|
|
|
}
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ interop_augment_args -b --derived
|
|
|
|
Value of built: true
|
|
|
|
Value of derived via ArgMatches: true
|
|
|
|
Value of derived: DerivedArgs {
|
|
|
|
derived: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ interop_augment_args -d --built
|
|
|
|
Value of built: true
|
|
|
|
Value of derived via ArgMatches: true
|
|
|
|
Value of derived: DerivedArgs {
|
|
|
|
derived: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ interop_augment_args --unknown
|
|
|
|
? failed
|
2023-01-14 03:29:49 +00:00
|
|
|
error: unexpected argument '--unknown' found
|
2022-03-07 20:43:51 +00:00
|
|
|
|
2022-09-07 16:03:55 +00:00
|
|
|
Usage: interop_augment_args[EXE] [OPTIONS]
|
2022-03-07 20:43:51 +00:00
|
|
|
|
2023-01-03 19:22:35 +00:00
|
|
|
For more information, try '--help'.
|
2022-03-07 20:43:51 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
## Augment Subcommands
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ interop_augment_subcommands
|
|
|
|
? failed
|
|
|
|
error: A subcommand is required but one was not provided.
|
|
|
|
```
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ interop_augment_subcommands derived
|
|
|
|
Derived subcommands: Derived {
|
|
|
|
derived_flag: false,
|
|
|
|
}
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ interop_augment_subcommands derived --derived-flag
|
|
|
|
Derived subcommands: Derived {
|
|
|
|
derived_flag: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ interop_augment_subcommands derived --unknown
|
|
|
|
? failed
|
2023-01-14 03:29:49 +00:00
|
|
|
error: unexpected argument '--unknown' found
|
2022-03-07 20:43:51 +00:00
|
|
|
|
2022-09-07 16:03:55 +00:00
|
|
|
Usage: interop_augment_subcommands[EXE] derived [OPTIONS]
|
2022-03-07 20:43:51 +00:00
|
|
|
|
2023-01-03 19:22:35 +00:00
|
|
|
For more information, try '--help'.
|
2022-03-07 20:43:51 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ interop_augment_subcommands unknown
|
|
|
|
? failed
|
2023-01-06 23:01:34 +00:00
|
|
|
error: unrecognized subcommand 'unknown'
|
2022-03-07 20:43:51 +00:00
|
|
|
|
2022-09-07 16:03:55 +00:00
|
|
|
Usage: interop_augment_subcommands[EXE] [COMMAND]
|
2022-03-07 20:43:51 +00:00
|
|
|
|
2023-01-03 19:22:35 +00:00
|
|
|
For more information, try '--help'.
|
2022-03-07 20:43:51 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
## Hand-Implemented Subcommand
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ interop_hand_subcommand
|
|
|
|
? failed
|
2022-09-07 16:03:55 +00:00
|
|
|
Usage: interop_hand_subcommand[EXE] [OPTIONS] <COMMAND>
|
2022-03-07 20:43:51 +00:00
|
|
|
|
2022-08-31 02:38:37 +00:00
|
|
|
Commands:
|
2022-09-07 20:29:15 +00:00
|
|
|
add
|
|
|
|
remove
|
|
|
|
help Print this message or the help of the given subcommand(s)
|
2022-03-07 20:43:51 +00:00
|
|
|
|
2022-08-26 15:59:27 +00:00
|
|
|
Options:
|
2022-09-07 20:29:15 +00:00
|
|
|
-t, --top-level
|
2023-01-03 16:49:43 +00:00
|
|
|
-h, --help Print help
|
2022-08-26 15:59:27 +00:00
|
|
|
|
2022-03-07 20:43:51 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ interop_hand_subcommand add
|
|
|
|
Cli {
|
|
|
|
top_level: false,
|
|
|
|
subcommand: Add(
|
|
|
|
AddArgs {
|
|
|
|
name: [],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
}
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ interop_hand_subcommand add a b c
|
|
|
|
Cli {
|
|
|
|
top_level: false,
|
|
|
|
subcommand: Add(
|
|
|
|
AddArgs {
|
|
|
|
name: [
|
|
|
|
"a",
|
|
|
|
"b",
|
|
|
|
"c",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
}
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ interop_hand_subcommand add --unknown
|
|
|
|
? failed
|
2023-01-14 03:29:49 +00:00
|
|
|
error: unexpected argument '--unknown' found
|
2022-03-07 20:43:51 +00:00
|
|
|
|
2023-03-28 01:18:18 +00:00
|
|
|
tip: to pass '--unknown' as a value, use '-- --unknown'
|
2022-03-07 20:43:51 +00:00
|
|
|
|
2022-09-07 16:03:55 +00:00
|
|
|
Usage: interop_hand_subcommand[EXE] add [NAME]...
|
2022-03-07 20:43:51 +00:00
|
|
|
|
2023-01-03 19:22:35 +00:00
|
|
|
For more information, try '--help'.
|
2022-03-07 20:43:51 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ interop_hand_subcommand remove
|
|
|
|
Cli {
|
|
|
|
top_level: false,
|
|
|
|
subcommand: Remove(
|
|
|
|
RemoveArgs {
|
|
|
|
force: false,
|
|
|
|
name: [],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
}
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ interop_hand_subcommand remove --force a b c
|
|
|
|
Cli {
|
|
|
|
top_level: false,
|
|
|
|
subcommand: Remove(
|
|
|
|
RemoveArgs {
|
|
|
|
force: true,
|
|
|
|
name: [
|
|
|
|
"a",
|
|
|
|
"b",
|
|
|
|
"c",
|
|
|
|
],
|
|
|
|
},
|
|
|
|
),
|
|
|
|
}
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ interop_hand_subcommand unknown
|
|
|
|
? failed
|
2023-01-06 23:01:34 +00:00
|
|
|
error: unrecognized subcommand 'unknown'
|
2022-03-07 20:43:51 +00:00
|
|
|
|
2022-09-07 16:03:55 +00:00
|
|
|
Usage: interop_hand_subcommand[EXE] [OPTIONS] <COMMAND>
|
2022-03-07 20:43:51 +00:00
|
|
|
|
2023-01-03 19:22:35 +00:00
|
|
|
For more information, try '--help'.
|
2022-03-07 20:43:51 +00:00
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
## Flatten Hand-Implemented Args
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ interop_flatten_hand_args
|
|
|
|
Cli {
|
|
|
|
top_level: false,
|
|
|
|
more_args: CliArgs {
|
|
|
|
foo: false,
|
|
|
|
bar: false,
|
|
|
|
quuz: None,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ interop_flatten_hand_args -f --bar
|
|
|
|
Cli {
|
|
|
|
top_level: false,
|
|
|
|
more_args: CliArgs {
|
|
|
|
foo: true,
|
|
|
|
bar: true,
|
|
|
|
quuz: None,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ interop_flatten_hand_args --quuz abc
|
|
|
|
Cli {
|
|
|
|
top_level: false,
|
|
|
|
more_args: CliArgs {
|
|
|
|
foo: false,
|
|
|
|
bar: false,
|
|
|
|
quuz: Some(
|
|
|
|
"abc",
|
|
|
|
),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ interop_flatten_hand_args --unknown
|
|
|
|
? failed
|
2023-01-14 03:29:49 +00:00
|
|
|
error: unexpected argument '--unknown' found
|
2022-03-07 20:43:51 +00:00
|
|
|
|
2022-09-07 16:03:55 +00:00
|
|
|
Usage: interop_flatten_hand_args[EXE] [OPTIONS]
|
2022-03-07 20:43:51 +00:00
|
|
|
|
2023-01-03 19:22:35 +00:00
|
|
|
For more information, try '--help'.
|
2022-03-07 20:43:51 +00:00
|
|
|
|
|
|
|
```
|