Make `convert` the default subcommand for `preserves-tool`
This commit is contained in:
parent
c5bec4ea76
commit
694d4e7ae7
|
@ -5,20 +5,29 @@ title: preserves-tool
|
|||
The `preserves-tool` program is a swiss army knife for working with
|
||||
Preserves documents.
|
||||
|
||||
preserves-tools 1.0.0
|
||||
```
|
||||
preserves-tool 4.992.0
|
||||
Swiss-army knife tool for working with Preserves data.
|
||||
See https://preserves.dev/. If no subcommand is specified, the default
|
||||
subcommand will be `convert`.
|
||||
|
||||
USAGE:
|
||||
preserves-tool <SUBCOMMAND>
|
||||
USAGE:
|
||||
preserves-tool [OPTIONS]
|
||||
preserves-tool <SUBCOMMAND>
|
||||
|
||||
FLAGS:
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
OPTIONS:
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
|
||||
SUBCOMMANDS:
|
||||
completions
|
||||
convert
|
||||
help Print this message or the help of the given subcommand(s)
|
||||
quote
|
||||
OPTIONS FOR DEFAULT SUBCOMMAND convert:
|
||||
[...]
|
||||
|
||||
SUBCOMMANDS:
|
||||
completions
|
||||
convert
|
||||
help Print this message or the help of the given subcommand(s)
|
||||
quote
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
|
@ -31,9 +40,10 @@ Then, `cargo install preserves-tools`.
|
|||
|
||||
The tool includes three subcommands.
|
||||
|
||||
### `preserves-tool convert`
|
||||
### `preserves-tool convert`, `preserves-tool`
|
||||
|
||||
This is the main tool. It can
|
||||
This is the main tool, and is also the default if no subcommand is
|
||||
explicitly specified. It can
|
||||
|
||||
- translate between the various Preserves text and binary document
|
||||
syntaxes;
|
||||
|
@ -48,38 +58,45 @@ This is the main tool. It can
|
|||
USAGE:
|
||||
preserves-tool convert [FLAGS] [OPTIONS]
|
||||
|
||||
FLAGS:
|
||||
--collect
|
||||
--escape-spaces
|
||||
-h, --help Prints help information
|
||||
-V, --version Prints version information
|
||||
|
||||
OPTIONS:
|
||||
--bundle <filename>...
|
||||
-c, --commas <commas>
|
||||
--bundle <filename>
|
||||
|
||||
|
||||
-c, --commas <COMMAS>
|
||||
[default: none] [possible values: none, separating, terminating]
|
||||
|
||||
--indent <on/off>
|
||||
[default: on] [possible values: disabled, no, n, off, 0, false,
|
||||
enabled, yes, y, on, 1, true]
|
||||
--collect
|
||||
|
||||
-i, --input-format <input-format>
|
||||
|
||||
--escape-spaces
|
||||
|
||||
|
||||
-h, --help
|
||||
Print help information
|
||||
|
||||
-i, --input-format <INPUT_FORMAT>
|
||||
[default: auto-detect] [possible values: auto-detect, text, binary]
|
||||
|
||||
--limit <limit>
|
||||
-o, --output-format <output-format>
|
||||
[default: text] [possible values: text, binary, unquoted]
|
||||
--read-annotations <on/off>
|
||||
[default: on] [possible values: disabled, no, n, off, 0, false,
|
||||
enabled, yes, y, on, 1, true]
|
||||
--indent <on/off>
|
||||
[default: on] [possible values: disabled, enabled]
|
||||
|
||||
--schema <schema>
|
||||
--select <select-expr> [default: *]
|
||||
--select-output <select-output>
|
||||
--limit <LIMIT>
|
||||
|
||||
|
||||
-o, --output-format <OUTPUT_FORMAT>
|
||||
[default: text] [possible values: text, binary, unquoted]
|
||||
|
||||
--read-annotations <on/off>
|
||||
[default: on] [possible values: disabled, enabled]
|
||||
|
||||
--select <SELECT_EXPR>
|
||||
[default: *]
|
||||
|
||||
--select-output <SELECT_OUTPUT>
|
||||
[default: sequence] [possible values: sequence, set]
|
||||
|
||||
--write-annotations <on/off>
|
||||
[default: on] [possible values: disabled, no, n, off, 0, false,
|
||||
enabled, yes, y, on, 1, true]
|
||||
[default: on] [possible values: disabled, enabled]
|
||||
|
||||
### `preserves-tool quote`
|
||||
|
||||
|
@ -101,12 +118,10 @@ preserves-tool-quote
|
|||
USAGE:
|
||||
preserves-tool quote [OPTIONS] <SUBCOMMAND>
|
||||
|
||||
FLAGS:
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
|
||||
OPTIONS:
|
||||
-o, --output-format <OUTPUT_FORMAT> [default: text] [possible values: text, binary, unquoted]
|
||||
-h, --help Print help information
|
||||
-o, --output-format <OUTPUT_FORMAT> [default: text] [possible values: text,
|
||||
binary, unquoted]
|
||||
|
||||
SUBCOMMANDS:
|
||||
byte-string
|
||||
|
@ -119,32 +134,28 @@ SUBCOMMANDS:
|
|||
preserves-tool-quote-string
|
||||
|
||||
USAGE:
|
||||
preserves-tool quote string [FLAGS] [OPTIONS]
|
||||
|
||||
FLAGS:
|
||||
--escape-spaces
|
||||
-h, --help Print help information
|
||||
--include-terminator
|
||||
-V, --version Print version information
|
||||
preserves-tool quote string [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
--input-terminator <INPUT_TERMINATOR> [default: eof] [possible values: eof, newline, nul]
|
||||
--escape-spaces
|
||||
-h, --help Print help information
|
||||
--include-terminator
|
||||
--input-terminator <INPUT_TERMINATOR> [default: eof] [possible values:
|
||||
eof, newline, nul]
|
||||
```
|
||||
|
||||
```
|
||||
preserves-tool-quote-symbol
|
||||
|
||||
USAGE:
|
||||
preserves-tool quote symbol [FLAGS] [OPTIONS]
|
||||
|
||||
FLAGS:
|
||||
--escape-spaces
|
||||
-h, --help Print help information
|
||||
--include-terminator
|
||||
-V, --version Print version information
|
||||
preserves-tool quote symbol [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
--input-terminator <INPUT_TERMINATOR> [default: eof] [possible values: eof, newline, nul]
|
||||
--escape-spaces
|
||||
-h, --help Print help information
|
||||
--include-terminator
|
||||
--input-terminator <INPUT_TERMINATOR> [default: eof] [possible values:
|
||||
eof, newline, nul]
|
||||
```
|
||||
|
||||
```
|
||||
|
@ -153,9 +164,8 @@ preserves-tool-quote-byte-string
|
|||
USAGE:
|
||||
preserves-tool quote byte-string
|
||||
|
||||
FLAGS:
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
OPTIONS:
|
||||
-h, --help Print help information
|
||||
```
|
||||
|
||||
### `preserves-tool completions`
|
||||
|
@ -176,12 +186,11 @@ Multiple shell dialects are supported (courtesy of
|
|||
preserves-tool-completions
|
||||
|
||||
USAGE:
|
||||
preserves-tool completions <dialect>
|
||||
preserves-tool completions <SHELL>
|
||||
|
||||
ARGS:
|
||||
<dialect> [possible values: bash, zsh, power-shell, fish, elvish]
|
||||
<SHELL> [possible values: bash, elvish, fish, powershell, zsh]
|
||||
|
||||
FLAGS:
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
OPTIONS:
|
||||
-h, --help Print help information
|
||||
```
|
||||
|
|
|
@ -177,9 +177,16 @@ enum Subcommand {
|
|||
#[derive(Clone, Debug, Parser)]
|
||||
#[clap(name = "preserves-tool")]
|
||||
#[clap(version)]
|
||||
#[clap(args_conflicts_with_subcommands = true)]
|
||||
/// Swiss-army knife tool for working with Preserves data.
|
||||
/// See https://preserves.dev/.
|
||||
/// If no subcommand is specified, the default subcommand will be `convert`.
|
||||
struct CommandLine {
|
||||
#[clap(subcommand)]
|
||||
command: Subcommand,
|
||||
command: Option<Subcommand>,
|
||||
|
||||
#[clap(flatten, next_help_heading="OPTIONS FOR DEFAULT SUBCOMMAND convert")]
|
||||
convert: Convert,
|
||||
}
|
||||
|
||||
fn print_completions<G: Generator>(gen: G, cmd: &mut Command) {
|
||||
|
@ -189,12 +196,15 @@ fn print_completions<G: Generator>(gen: G, cmd: &mut Command) {
|
|||
fn main() -> io::Result<()> {
|
||||
let args = CommandLine::parse();
|
||||
Ok(match args.command {
|
||||
Subcommand::Completions { shell } => {
|
||||
let mut cmd = CommandLine::into_app();
|
||||
print_completions(shell, &mut cmd);
|
||||
Some(subcommand) => match subcommand {
|
||||
Subcommand::Completions { shell } => {
|
||||
let mut cmd = CommandLine::into_app();
|
||||
print_completions(shell, &mut cmd);
|
||||
}
|
||||
Subcommand::Convert(c) => convert(c)?,
|
||||
Subcommand::Quote(q) => quote(q)?,
|
||||
}
|
||||
Subcommand::Convert(c) => convert(c)?,
|
||||
Subcommand::Quote(q) => quote(q)?,
|
||||
None => convert(args.convert)?,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue