Skip to content

Commit

Permalink
rename default to value
Browse files Browse the repository at this point in the history
  • Loading branch information
tertsdiepraam committed Dec 7, 2023
1 parent 2ba46a2 commit 19cf7bd
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion derive/src/argument.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub fn parse_argument(v: Variant) -> Vec<Argument> {
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()),
};
Expand Down
6 changes: 3 additions & 3 deletions derive/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl ArgAttr {
pub struct OptionAttr {
pub flags: Flags,
pub parser: Option<Expr>,
pub default: Option<Expr>,
pub value: Option<Expr>,
pub hidden: bool,
pub help: Option<String>,
}
Expand All @@ -123,10 +123,10 @@ impl OptionAttr {
let p = s.parse::<Expr>()?;
option_attr.parser = Some(p);
}
"default" => {
"value" => {
s.parse::<Token![=]>()?;
let d = s.parse::<Expr>()?;
option_attr.default = Some(d);
option_attr.value = Some(d);
}
"hidden" => {
option_attr.hidden = true;
Expand Down
34 changes: 17 additions & 17 deletions tests/coreutils/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ===
Expand Down Expand Up @@ -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
Expand All @@ -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 ===
Expand Down Expand Up @@ -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 ?
Expand Down
2 changes: 1 addition & 1 deletion tests/coreutils/mktemp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion tests/coreutils/tail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
4 changes: 2 additions & 2 deletions tests/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ fn ls_classify() {
enum Arg {
#[arg(
"-F", "--classify[=WHEN]",
default = When::Always,
value = When::Always,
)]
Classify(When),
}
Expand Down Expand Up @@ -397,7 +397,7 @@ fn mktemp_tmpdir() {
enum Arg {
#[arg(
"-p DIR", "--tmpdir[=DIR]",
default = String::from("/tmp"),
value = String::from("/tmp"),
)]
TmpDir(String),
}
Expand Down

0 comments on commit 19cf7bd

Please sign in to comment.