From df69b35c250eff5858d6e994a9866be35b987a6e Mon Sep 17 00:00:00 2001 From: datdenkikniet Date: Sat, 15 Apr 2023 13:18:18 +0200 Subject: More housekeeping and making it work that bit better --- xtask/src/argument_parsing.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'xtask/src/argument_parsing.rs') diff --git a/xtask/src/argument_parsing.rs b/xtask/src/argument_parsing.rs index 77433ee..3a89dfc 100644 --- a/xtask/src/argument_parsing.rs +++ b/xtask/src/argument_parsing.rs @@ -209,7 +209,8 @@ pub enum Commands { FormatCheck(PackageOpt), /// Format code - Format(PackageOpt), + #[clap(alias = "fmt")] + Format(FormatOpt), /// Run clippy Clippy(PackageOpt), @@ -265,6 +266,15 @@ pub enum Commands { Book(Arg), } +#[derive(Args, Debug, Clone)] +pub struct FormatOpt { + #[clap(flatten)] + pub package: PackageOpt, + /// Only check formatting, without applying fixes. + #[clap(short, long, alias = "check-only")] + pub check: bool, +} + #[derive(Args, Debug, Clone)] /// Restrict to package, or run on whole workspace pub struct PackageOpt { @@ -315,3 +325,13 @@ pub enum ExtraArguments { #[command(external_subcommand)] Other(Vec), } + +impl core::fmt::Display for ExtraArguments { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + ExtraArguments::Other(args) => { + write!(f, "{}", args.join(" ")) + } + } + } +} -- cgit v1.2.3