diff --git a/derive/src/argument.rs b/derive/src/argument.rs index 7e3928a..ee09c76 100644 --- a/derive/src/argument.rs +++ b/derive/src/argument.rs @@ -78,7 +78,7 @@ pub fn parse_argument(v: Variant) -> Vec { let mut arg_help = help.clone(); let arg_type = match attribute { ArgAttr::Option(opt) => { - let default_expr = match opt.default { + let default_expr = match opt.value { Some(expr) => quote!(#expr), None => quote!(Default::default()), }; diff --git a/derive/src/attributes.rs b/derive/src/attributes.rs index fc56dc7..1a77353 100644 --- a/derive/src/attributes.rs +++ b/derive/src/attributes.rs @@ -100,7 +100,7 @@ impl ArgAttr { pub struct OptionAttr { pub flags: Flags, pub parser: Option, - pub default: Option, + pub value: Option, pub hidden: bool, pub help: Option, } @@ -123,10 +123,10 @@ impl OptionAttr { let p = s.parse::()?; option_attr.parser = Some(p); } - "default" => { + "value" => { s.parse::()?; let d = s.parse::()?; - option_attr.default = Some(d); + option_attr.value = Some(d); } "hidden" => { option_attr.hidden = true; diff --git a/tests/coreutils/ls.rs b/tests/coreutils/ls.rs index 4e3e6de..1ebcfa4 100644 --- a/tests/coreutils/ls.rs +++ b/tests/coreutils/ls.rs @@ -146,17 +146,17 @@ enum Arg { Author, #[arg("--time=WORD")] - #[arg("-c", default = Time::Change)] - #[arg("-u", default = Time::Access)] + #[arg("-c", value = Time::Change)] + #[arg("-u", value = Time::Access)] Time(Time), // === Sorting == /// Sort by WORD #[arg("--sort=WORD")] - #[arg("-t", default = Sort::Time, help = "Sort by time")] - #[arg("-U", default = Sort::None, help = "Do not sort")] - #[arg("-v", default = Sort::Version, help = "Sort by version")] - #[arg("-X", default = Sort::Extension, help = "Sort by extension")] + #[arg("-t", value = Sort::Time, help = "Sort by time")] + #[arg("-U", value = Sort::None, help = "Do not sort")] + #[arg("-v", value = Sort::Version, help = "Sort by version")] + #[arg("-X", value = Sort::Extension, help = "Sort by extension")] Sort(Sort), // === Miscellaneous === @@ -200,10 +200,10 @@ enum Arg { // === Format === /// Set format #[arg("--format=FORMAT")] - #[arg("-l", "--long", default = Format::Long, help = "Use long format")] - #[arg("-C", default = Format::Columns, help = "Use columns format")] - #[arg("-x", default = Format::Across, help = "Use across format")] - #[arg("-m", default = Format::Commas, help = "Use comma format")] + #[arg("-l", "--long", value = Format::Long, help = "Use long format")] + #[arg("-C", value = Format::Columns, help = "Use columns format")] + #[arg("-x", value = Format::Across, help = "Use across format")] + #[arg("-m", value = Format::Commas, help = "Use comma format")] Format(Format), /// Show single column @@ -221,12 +221,12 @@ enum Arg { // === Indicator style === #[arg("--indicator-style=STYLE")] - #[arg("-p", default = IndicatorStyle::Slash, help = "Append slash to directories")] - #[arg("--file-type", default = IndicatorStyle::FileType, help = "Add indicators for file types")] + #[arg("-p", value = IndicatorStyle::Slash, help = "Append slash to directories")] + #[arg("--file-type", value = IndicatorStyle::FileType, help = "Add indicators for file types")] IndicatorStyle(IndicatorStyle), /// Classify items - #[arg("-F", "--classify[=WHEN]", default = When::Always)] + #[arg("-F", "--classify[=WHEN]", value = When::Always)] IndicatorStyleClassify(When), // === Dereference === @@ -254,13 +254,13 @@ enum Arg { // === Quoting style === #[arg("--quoting-style=STYLE")] - #[arg("-N", "--literal", default = QuotingStyle::Literal)] - #[arg("-h", "--escape", default = QuotingStyle::Escape)] - #[arg("-Q", "--quote-name", default = todo!())] + #[arg("-N", "--literal", value = QuotingStyle::Literal)] + #[arg("-h", "--escape", value = QuotingStyle::Escape)] + #[arg("-Q", "--quote-name", value = todo!())] QuotingStyle(QuotingStyle), /// Set the color - #[arg("--color[=WHEN]", default = When::Always)] + #[arg("--color[=WHEN]", value = When::Always)] Color(When), /// Print control characters as ? diff --git a/tests/coreutils/mktemp.rs b/tests/coreutils/mktemp.rs index c713eef..344cb06 100644 --- a/tests/coreutils/mktemp.rs +++ b/tests/coreutils/mktemp.rs @@ -19,7 +19,7 @@ enum Arg { #[arg("-t")] TreatAsTemplate, - #[arg("-p DIR", "--tmpdir[=DIR]", default = ".".into())] + #[arg("-p DIR", "--tmpdir[=DIR]", value = ".".into())] TmpDir(PathBuf), #[arg("TEMPLATE", 0..=1)] diff --git a/tests/coreutils/tail.rs b/tests/coreutils/tail.rs index 31cfda9..671b9be 100644 --- a/tests/coreutils/tail.rs +++ b/tests/coreutils/tail.rs @@ -109,7 +109,7 @@ enum Arg { #[arg("-c NUM", "--bytes=NUM")] Bytes(SigNum), - #[arg("-f", "--follow[=HOW]", default=FollowMode::Descriptor)] + #[arg("-f", "--follow[=HOW]", value = FollowMode::Descriptor)] Follow(FollowMode), #[arg("-F")] diff --git a/tests/options.rs b/tests/options.rs index 729a107..d52dfe7 100644 --- a/tests/options.rs +++ b/tests/options.rs @@ -357,7 +357,7 @@ fn ls_classify() { enum Arg { #[arg( "-F", "--classify[=WHEN]", - default = When::Always, + value = When::Always, )] Classify(When), } @@ -397,7 +397,7 @@ fn mktemp_tmpdir() { enum Arg { #[arg( "-p DIR", "--tmpdir[=DIR]", - default = String::from("/tmp"), + value = String::from("/tmp"), )] TmpDir(String), }