enhance/hurlfmt: remove depreciated --format option

This commit is contained in:
Bhuwan Pandit 2024-11-26 21:11:41 +00:00 committed by hurl-bot
parent 59dbec80e7
commit 4660d35473
No known key found for this signature in database
GPG Key ID: 1283A2B4A0DCAF8D
9 changed files with 2 additions and 35 deletions

View File

@ -17,7 +17,6 @@ _hurlfmt() {
_arguments "${_arguments_options[@]}" \ _arguments "${_arguments_options[@]}" \
'--check[Run in check mode]' \ '--check[Run in check mode]' \
'--color[Colorize Output]' \ '--color[Colorize Output]' \
'--format[Specify output format: hurl, json or html]: :' \
'--in-place[Modify files in place]' \ '--in-place[Modify files in place]' \
'--in[Specify input format: hurl or curl]: :' \ '--in[Specify input format: hurl or curl]: :' \
'--no-color[Do not colorize output]' \ '--no-color[Do not colorize output]' \

View File

@ -22,7 +22,6 @@ Register-ArgumentCompleter -Native -CommandName 'hurlfmt' -ScriptBlock {
'hurlfmt' 'hurlfmt'
{[CompletionResult]::new('--check', 'check', [CompletionResultType]::ParameterName, 'Run in check mode') {[CompletionResult]::new('--check', 'check', [CompletionResultType]::ParameterName, 'Run in check mode')
[CompletionResult]::new('--color', 'color', [CompletionResultType]::ParameterName, 'Colorize Output') [CompletionResult]::new('--color', 'color', [CompletionResultType]::ParameterName, 'Colorize Output')
[CompletionResult]::new('--format', 'format', [CompletionResultType]::ParameterName, 'Specify output format: hurl, json or html')
[CompletionResult]::new('--in-place', 'in-place', [CompletionResultType]::ParameterName, 'Modify files in place') [CompletionResult]::new('--in-place', 'in-place', [CompletionResultType]::ParameterName, 'Modify files in place')
[CompletionResult]::new('--in', 'in', [CompletionResultType]::ParameterName, 'Specify input format: hurl or curl') [CompletionResult]::new('--in', 'in', [CompletionResultType]::ParameterName, 'Specify input format: hurl or curl')
[CompletionResult]::new('--no-color', 'no-color', [CompletionResultType]::ParameterName, 'Do not colorize output') [CompletionResult]::new('--no-color', 'no-color', [CompletionResultType]::ParameterName, 'Do not colorize output')

View File

@ -5,7 +5,7 @@ _hurlfmt()
_init_completion || return _init_completion || return
if [[ $cur == -* ]]; then if [[ $cur == -* ]]; then
COMPREPLY=($(compgen -W '--check --color --format --in-place --in --no-color --output --out --standalone --help --version' -- "$cur")) COMPREPLY=($(compgen -W '--check --color --in-place --in --no-color --output --out --standalone --help --version' -- "$cur"))
return return
fi fi

View File

@ -1,6 +1,5 @@
complete -c hurlfmt -l check -d 'Run in check mode' complete -c hurlfmt -l check -d 'Run in check mode'
complete -c hurlfmt -l color -d 'Colorize Output' complete -c hurlfmt -l color -d 'Colorize Output'
complete -c hurlfmt -l format -d 'Specify output format: hurl, json or html'
complete -c hurlfmt -l in-place -d 'Modify files in place' complete -c hurlfmt -l in-place -d 'Modify files in place'
complete -c hurlfmt -l in -d 'Specify input format: hurl or curl' complete -c hurlfmt -l in -d 'Specify input format: hurl or curl'
complete -c hurlfmt -l no-color -d 'Do not colorize output' complete -c hurlfmt -l no-color -d 'Do not colorize output'

View File

@ -1,7 +1,7 @@
name: check name: check
long: check long: check
help: Run in check mode help: Run in check mode
conflict: format output conflict: output
--- ---
Run in check mode. Exits with 0 if input is formatted correctly, 1 otherwise. Run in check mode. Exits with 0 if input is formatted correctly, 1 otherwise.

View File

@ -1,7 +0,0 @@
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

@ -30,7 +30,6 @@ 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")
.conflicts_with("format")
.conflicts_with("output") .conflicts_with("output")
.action(clap::ArgAction::SetTrue) .action(clap::ArgAction::SetTrue)
} }
@ -44,15 +43,6 @@ pub fn color() -> clap::Arg {
.action(clap::ArgAction::SetTrue) .action(clap::ArgAction::SetTrue)
} }
pub fn format() -> clap::Arg {
clap::Arg::new("format")
.long("format")
.value_name("FORMAT")
.help("Specify output format: hurl, json or html")
.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")

View File

@ -19,7 +19,6 @@ use std::io;
use std::io::IsTerminal; use std::io::IsTerminal;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use clap::parser::ValueSource;
use clap::ArgMatches; use clap::ArgMatches;
use hurl_core::input::Input; use hurl_core::input::Input;
@ -49,17 +48,6 @@ pub fn input_format(arg_matches: &ArgMatches) -> Result<InputFormat, OptionsErro
} }
pub fn output_format(arg_matches: &ArgMatches) -> Result<OutputFormat, OptionsError> { pub fn output_format(arg_matches: &ArgMatches) -> Result<OutputFormat, OptionsError> {
// Deprecated --format option
if arg_matches.value_source("format") == Some(ValueSource::CommandLine) {
eprintln!("--format is deprecated. use --out instead.");
return match get_string(arg_matches, "format").unwrap().as_str() {
"hurl" => Ok(OutputFormat::Hurl),
"json" => Ok(OutputFormat::Json),
"html" => Ok(OutputFormat::Html),
v => Err(OptionsError::Error(format!("Invalid output format {v}"))),
};
}
match get_string(arg_matches, "output_format").unwrap().as_str() { match get_string(arg_matches, "output_format").unwrap().as_str() {
"hurl" => Ok(OutputFormat::Hurl), "hurl" => Ok(OutputFormat::Hurl),
"json" => Ok(OutputFormat::Json), "json" => Ok(OutputFormat::Json),

View File

@ -73,7 +73,6 @@ pub fn parse() -> Result<Options, OptionsError> {
.about("Format Hurl files") .about("Format Hurl files")
.arg(commands::check()) .arg(commands::check())
.arg(commands::color()) .arg(commands::color())
.arg(commands::format())
.arg(commands::in_place()) .arg(commands::in_place())
.arg(commands::input_files()) .arg(commands::input_files())
.arg(commands::input_format()) .arg(commands::input_format())