difftreelog
fix(cli) yaml format should be used by default, when -y is passed
in: master
1 file changed
crates/jrsonnet-cli/src/manifest.rsdiffbeforeafterboth6};6};7use jrsonnet_stdlib::{TomlFormat, YamlFormat};7use jrsonnet_stdlib::{TomlFormat, YamlFormat};889#[derive(Clone, ValueEnum)]9#[derive(Clone, Copy, ValueEnum)]10pub enum ManifestFormatName {10pub enum ManifestFormatName {11 /// Expect string as output, and write them directly11 /// Expect string as output, and write them directly12 String,12 String,18#[derive(Parser)]18#[derive(Parser)]19#[clap(next_help_heading = "MANIFESTIFICATION OUTPUT")]19#[clap(next_help_heading = "MANIFESTIFICATION OUTPUT")]20pub struct ManifestOpts {20pub struct ManifestOpts {21 /// Output format, wraps resulting value to corresponding std.manifest call.21 /// Output format, wraps resulting value to corresponding std.manifest call22 ///23 /// [default: json, yaml when -y is used]22 #[clap(long, short = 'f', default_value = "json")]24 #[clap(long, short = 'f')]23 format: ManifestFormatName,25 format: Option<ManifestFormatName>,24 /// Expect plain string as output.26 /// Expect plain string as output.25 /// Mutually exclusive with `--format`27 /// Mutually exclusive with `--format`26 #[clap(long, short = 'S', conflicts_with = "format")]28 #[clap(long, short = 'S', conflicts_with = "format")]29 #[clap(long, short = 'y', conflicts_with = "string")]31 #[clap(long, short = 'y', conflicts_with = "string")]30 yaml_stream: bool,32 yaml_stream: bool,31 /// Number of spaces to pad output manifest with.33 /// Number of spaces to pad output manifest with.32 /// `0` for hard tabs, `-1` for single line output [default: 3 for json, 2 for yaml/toml]34 /// `0` for hard tabs, `-1` for single line output35 ///36 /// [default: 3 for json, 2 for yaml/toml]33 #[clap(long)]37 #[clap(long)]34 line_padding: Option<usize>,38 line_padding: Option<usize>,35 /// Preserve order in object manifestification39 /// Preserve order in object manifestification44 } else {48 } else {45 #[cfg(feature = "exp-preserve-order")]49 #[cfg(feature = "exp-preserve-order")]46 let preserve_order = self.preserve_order;50 let preserve_order = self.preserve_order;51 let format = match self.format {52 Some(v) => v,53 None if self.yaml_stream => ManifestFormatName::Yaml,54 None => ManifestFormatName::Json,55 };47 match self.format {56 match format {48 ManifestFormatName::String => Box::new(ToStringFormat),57 ManifestFormatName::String => Box::new(ToStringFormat),49 ManifestFormatName::Json => Box::new(JsonFormat::cli(58 ManifestFormatName::Json => Box::new(JsonFormat::cli(50 self.line_padding.unwrap_or(3),59 self.line_padding.unwrap_or(3),