Generate hurlfmt options source/doc from spec

This commit is contained in:
Fabrice Reix 2024-01-18 14:34:29 +01:00 committed by hurl-bot
parent 44ec1868ab
commit cda3770092
No known key found for this signature in database
GPG Key ID: 1283A2B4A0DCAF8D
13 changed files with 121 additions and 63 deletions

View File

@ -69,44 +69,33 @@ This can not be used with [--output](#output).
This option is not stable yet. This option is not stable yet.
### --color {#color} ### --color {#color}
Colorize Output. Colorize Output.
This can not be used [--in-place](#inplace). This can not be used [--in-place](#inplace).
### --in <FORMAT> {#in}
### -h, --help {#help} Specify input format: hurl or curl.
Usage help. ### --in-place {#in-place}
### --in {#input-format}
Specify input format: hurl (default) or curl
### --in-place {#inplace}
Modify file in place. Modify file in place.
This can be used only with text output. This can be used only with text output.
### --no-color {#no-color}
### --no-color {#nocolor} Do not colorize output.
Do not colorize Output. ### --out <FORMAT> {#out}
Specify output format: hurl, json or html.
### --out {#output-format} ### -o, --output <FILE> {#output}
Specify output format: hurl (default), json or html
### -o, --output <file> {#output}
Write output to <file> instead of stdout.
Write output to FILE instead of stdout.
### --standalone {#standalone} ### --standalone {#standalone}
@ -115,6 +104,11 @@ Output full html file with css instead of html fragment (default).
This can be used only with html output. This can be used only with html output.
### -h, --help {#help}
Usage help.
### -V, --version {#version} ### -V, --version {#version}
Prints version information Prints version information

View File

@ -18,6 +18,7 @@ This script insures that all `.option` files are well formatted.
```shell ```shell
$ bin/spec/options/generate_source.py docs/spec/options/hurl/*.option > packages/hurl/src/cli/options/commands.rs $ bin/spec/options/generate_source.py docs/spec/options/hurl/*.option > packages/hurl/src/cli/options/commands.rs
$ bin/spec/options/generate_source.py docs/spec/options/hurlfmt/*.option >packages/hurlfmt/src/cli/options/commands.rs
``` ```
This script generates Rust source file for parsing command line option. This script generates Rust source file for parsing command line option.
@ -26,6 +27,7 @@ This script generates Rust source file for parsing command line option.
```shell ```shell
$ bin/spec/options/generate_man.py docs/spec/options/hurl/*.option $ bin/spec/options/generate_man.py docs/spec/options/hurl/*.option
$ bin/spec/options/generate_man.py docs/spec/options/hurlfmt/*.option
``` ```
This script generates (part of) man file for `hurl` / `hurlfmt`. This script generates (part of) man file for `hurl` / `hurlfmt`.

View File

@ -0,0 +1,10 @@
name: check
long: check
help: Run in 'check' mode
---
Run in 'check' mode. Exits with 0 if input is formatted correctly, 1 otherwise.
This can not be used with [--output](#output).
This option is not stable yet.

View File

@ -0,0 +1,8 @@
name: color
long: color
help: Colorize Output
conflict: no_color, in_place
---
Colorize Output.
This can not be used [--in-place](#inplace).

View File

@ -0,0 +1,7 @@
name: format
long: format
value: FORMAT
help: Specify output format: hurl, json or html
deprecated: true
---
Specify output format: hurl, json or html.

View File

@ -0,0 +1,7 @@
name: in_place
long: in-place
help: Modify files in place
---
Modify file in place.
This can be used only with text output.

View File

@ -0,0 +1,7 @@
name: input_format
long: in
value: FORMAT
value_default: hurl
help: Specify input format: hurl or curl
---
Specify input format: hurl or curl.

View File

@ -0,0 +1,6 @@
name: no_color
long: no-color
help: Do not colorize output
conflict: color
---
Do not colorize output.

View File

@ -0,0 +1,7 @@
name: output
long: output
short: o
value: FILE
help: Write to FILE instead of stdout
---
Write output to FILE instead of stdout.

View File

@ -0,0 +1,7 @@
name: output_format
long: out
value: FORMAT
value_default: hurl
help: Specify output format: hurl, json or html
---
Specify output format: hurl, json or html.

View File

@ -0,0 +1,9 @@
name: standalone
long: standalone
help: Standalone HTML
conflict: no_color
---
Output full html file with css instead of html fragment (default).
This can be used only with html output.

View File

@ -3,13 +3,12 @@ Format Hurl files
Usage: hurlfmt [OPTIONS] [FILES]... Usage: hurlfmt [OPTIONS] [FILES]...
Arguments: Arguments:
[FILES]... Sets the input file to use [FILES]... Set the input file to use
Options: Options:
--check Run in 'check' mode --check Run in 'check' mode
--color Colorize Output --color Colorize Output
--format <FORMAT> Specify output format: hurl, json or html (DEPRECATED) [default: hurl] --in-place Modify files in place
--in-place Modify file in place
--in <FORMAT> Specify input format: hurl or curl [default: hurl] --in <FORMAT> Specify input format: hurl or curl [default: hurl]
--no-color Do not colorize output --no-color Do not colorize output
-o, --output <FILE> Write to FILE instead of stdout -o, --output <FILE> Write to FILE instead of stdout

View File

@ -15,75 +15,70 @@
* limitations under the License. * limitations under the License.
* *
*/ */
use clap::ArgAction; // Generated - Do not modify
pub fn input_files() -> clap::Arg {
clap::Arg::new("input_files")
.value_name("FILES")
.help("Set the input file to use")
.required(false)
.index(1)
.num_args(1..)
}
pub fn check() -> clap::Arg { pub fn check() -> clap::Arg {
clap::Arg::new("check") clap::Arg::new("check")
.long("check") .long("check")
.help("Run in 'check' mode") .help("Run in 'check' mode")
.action(ArgAction::SetTrue) .action(clap::ArgAction::SetTrue)
.conflicts_with("format")
.conflicts_with("output")
} }
pub fn color() -> clap::Arg { pub fn color() -> clap::Arg {
clap::Arg::new("color") clap::Arg::new("color")
.long("color") .long("color")
.help("Colorize Output") .help("Colorize Output")
.action(ArgAction::SetTrue)
.conflicts_with("no_color") .conflicts_with("no_color")
.conflicts_with("in_place") .conflicts_with("in_place")
.action(clap::ArgAction::SetTrue)
} }
pub fn format() -> clap::Arg { pub fn format() -> clap::Arg {
clap::Arg::new("format") clap::Arg::new("format")
.long("format") .long("format")
.value_name("FORMAT") .value_name("FORMAT")
.help("Specify output format: hurl, json or html (DEPRECATED)") .help("Specify output format: hurl, json or html")
.conflicts_with("check")
.default_value("hurl")
.num_args(1) .num_args(1)
.hide(true)
} }
pub fn in_place() -> clap::Arg { pub fn in_place() -> clap::Arg {
clap::Arg::new("in_place") clap::Arg::new("in_place")
.long("in-place") .long("in-place")
.help("Modify file in place") .help("Modify files in place")
.action(ArgAction::SetTrue) .action(clap::ArgAction::SetTrue)
.conflicts_with("output")
.conflicts_with("color")
}
pub fn input_files() -> clap::Arg {
clap::Arg::new("input_files")
.value_name("FILES")
.help("Sets the input file to use")
.required(false)
.index(1)
.num_args(1..)
} }
pub fn input_format() -> clap::Arg { pub fn input_format() -> clap::Arg {
clap::Arg::new("input_format") clap::Arg::new("input_format")
.long("in") .long("in")
.value_name("FORMAT") .value_name("FORMAT")
.help("Specify input format: hurl or curl")
.conflicts_with("check")
.default_value("hurl") .default_value("hurl")
.help("Specify input format: hurl or curl")
.num_args(1) .num_args(1)
} }
pub fn no_color() -> clap::Arg { pub fn no_color() -> clap::Arg {
clap::Arg::new("no_color") clap::Arg::new("no_color")
.long("no-color") .long("no-color")
.help("Do not colorize output") .help("Do not colorize output")
.action(ArgAction::SetTrue)
.conflicts_with("color") .conflicts_with("color")
.action(clap::ArgAction::SetTrue)
} }
pub fn output() -> clap::Arg { pub fn output() -> clap::Arg {
clap::Arg::new("output") clap::Arg::new("output")
.short('o')
.long("output") .long("output")
.short('o')
.value_name("FILE") .value_name("FILE")
.help("Write to FILE instead of stdout") .help("Write to FILE instead of stdout")
.num_args(1) .num_args(1)
@ -93,9 +88,8 @@ pub fn output_format() -> clap::Arg {
clap::Arg::new("output_format") clap::Arg::new("output_format")
.long("out") .long("out")
.value_name("FORMAT") .value_name("FORMAT")
.help("Specify output format: hurl, json or html")
.conflicts_with("check")
.default_value("hurl") .default_value("hurl")
.help("Specify output format: hurl, json or html")
.num_args(1) .num_args(1)
} }
@ -103,5 +97,6 @@ pub fn standalone() -> clap::Arg {
clap::Arg::new("standalone") clap::Arg::new("standalone")
.long("standalone") .long("standalone")
.help("Standalone HTML") .help("Standalone HTML")
.action(ArgAction::SetTrue) .conflicts_with("no_color")
.action(clap::ArgAction::SetTrue)
} }