Skip to content

Commit

Permalink
style: fix cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
39555 committed Oct 13, 2024
1 parent 46eeec4 commit 94202e3
Show file tree
Hide file tree
Showing 52 changed files with 25 additions and 74 deletions.
10 changes: 5 additions & 5 deletions brush-core/src/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,7 @@ fn brush_help_styles() -> clap::builder::Styles {
/// # Returns
///
/// * a parsed struct T from [`clap::Parser::parse_from`]
/// * the remain iterator `args` with `--` and the rest arguments if they present
/// othervise None
/// * the remain iterator `args` with `--` and the rest arguments if they present othervise None
///
/// # Examples
/// ```
Expand All @@ -421,8 +420,8 @@ where
S: Into<std::ffi::OsString> + Clone + PartialEq<&'static str>,
{
let mut args = args.into_iter();
// the best way to save `--` is to get it out with a side effect while `clap` iterates over the args
// this way we can be 100% sure that we have '--' and the remaining args
// the best way to save `--` is to get it out with a side effect while `clap` iterates over the
// args this way we can be 100% sure that we have '--' and the remaining args
// and we will iterate only once
let mut hyphen = None;
let args_before_hyphen = args.by_ref().take_while(|a| {
Expand All @@ -438,7 +437,8 @@ where
}

/// Similar to [`parse_known`] but with [`clap::Parser::try_parse_from`]
/// This function is used to parse arguments in builtins such as [`crate::builtins::echo::EchoCommand`]
/// This function is used to parse arguments in builtins such as
/// [`crate::builtins::echo::EchoCommand`]
pub fn try_parse_known<T: Parser>(
args: impl IntoIterator<Item = String>,
) -> Result<(T, Option<impl Iterator<Item = String>>), clap::Error> {
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub(crate) struct AliasCommand {
aliases: Vec<String>,
}


impl builtins::Command for AliasCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/bg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pub(crate) struct BgCommand {
job_specs: Vec<String>,
}


impl builtins::Command for BgCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/break_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pub(crate) struct BreakCommand {
which_loop: i8,
}


impl builtins::Command for BreakCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/brushinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ enum CompleteCommand {
},
}


impl builtins::Command for BrushInfoCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/builtin_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub(crate) struct BuiltinCommand {
args: Vec<String>,
}


impl builtins::Command for BuiltinCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/cd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ pub(crate) struct CdCommand {
target_dir: Option<PathBuf>,
}


impl builtins::Command for CdCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/colon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pub(crate) struct ColonCommand {
args: Vec<String>,
}


impl builtins::Command for ColonCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ pub(crate) struct CommandCommand {
args: Vec<String>,
}


impl builtins::Command for CommandCommand {
async fn execute(
&self,
Expand Down
3 changes: 0 additions & 3 deletions brush-core/src/builtins/complete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ pub(crate) struct CompleteCommand {
names: Vec<String>,
}


impl builtins::Command for CompleteCommand {
async fn execute(
&self,
Expand Down Expand Up @@ -435,7 +434,6 @@ pub(crate) struct CompGenCommand {
word: Option<String>,
}


impl builtins::Command for CompGenCommand {
async fn execute(
&self,
Expand Down Expand Up @@ -514,7 +512,6 @@ pub(crate) struct CompOptCommand {
names: Vec<String>,
}


impl builtins::Command for CompOptCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/continue_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pub(crate) struct ContinueCommand {
which_loop: i8,
}


impl builtins::Command for ContinueCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ impl builtins::DeclarationCommand for DeclareCommand {
}

#[allow(clippy::too_many_lines)]

impl builtins::Command for DeclareCommand {
fn takes_plus_options() -> bool {
true
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/dirs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ pub(crate) struct DirsCommand {
// TODO: implement +N and -N
}


impl builtins::Command for DirsCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/dot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub(crate) struct DotCommand {
pub script_args: Vec<String>,
}


impl builtins::Command for DotCommand {
async fn execute(
&self,
Expand Down
5 changes: 2 additions & 3 deletions brush-core/src/builtins/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ pub(crate) struct EchoCommand {
args: Vec<String>,
}


impl builtins::Command for EchoCommand {
/// Override the default [builtins::Command::new] function to handle clap's limitation related to `--`.
/// See [crate::builtins::parse_known] for more information
/// Override the default [builtins::Command::new] function to handle clap's limitation related
/// to `--`. See [crate::builtins::parse_known] for more information
/// TODO: we can safely remove this after the issue is resolved
fn new<I>(args: I) -> Result<Self, clap::Error>
where
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/enable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ pub(crate) struct EnableCommand {
names: Vec<String>,
}


impl builtins::Command for EnableCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pub(crate) struct EvalCommand {
pub args: Vec<String>,
}


impl builtins::Command for EvalCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub(crate) struct ExecCommand {
args: Vec<String>,
}


impl builtins::Command for ExecCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/exit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pub(crate) struct ExitCommand {
code: Option<i32>,
}


impl builtins::Command for ExitCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ impl builtins::DeclarationCommand for ExportCommand {
}
}


impl builtins::Command for ExportCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/false_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::{builtins, commands};
#[derive(Parser)]
pub(crate) struct FalseCommand {}


impl builtins::Command for FalseCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/fg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pub(crate) struct FgCommand {
job_spec: Option<String>,
}


impl builtins::Command for FgCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/getopts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ pub(crate) struct GetOptsCommand {
args: Vec<String>,
}


impl builtins::Command for GetOptsCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub(crate) struct HelpCommand {
topic_patterns: Vec<String>,
}


impl builtins::Command for HelpCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/jobs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ pub(crate) struct JobsCommand {
job_specs: Vec<String>,
}


impl builtins::Command for JobsCommand {
async fn execute(
&self,
Expand Down
2 changes: 0 additions & 2 deletions brush-core/src/builtins/kill.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub(crate) struct KillCommand {

//
// TODO: implement -sigspec syntax
//
/// List known signal names.
#[arg(short = 'l', short_alias = 'L')]
list_signals: bool,
Expand All @@ -25,7 +24,6 @@ pub(crate) struct KillCommand {
args: Vec<String>,
}


impl builtins::Command for KillCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/let_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ pub(crate) struct LetCommand {
exprs: Vec<String>,
}


impl builtins::Command for LetCommand {
async fn execute(
&self,
Expand Down
2 changes: 0 additions & 2 deletions brush-core/src/builtins/popd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ pub(crate) struct PopdCommand {
no_directory_change: bool,
//
// TODO: implement +N and -N
//
}


impl builtins::Command for PopdCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/printf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub(crate) struct PrintfCommand {
format_and_args: Vec<String>,
}


impl builtins::Command for PrintfCommand {
async fn execute(
&self,
Expand Down
2 changes: 0 additions & 2 deletions brush-core/src/builtins/pushd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ pub(crate) struct PushdCommand {
dir: String,
//
// TODO: implement +N and -N
//
}


impl builtins::Command for PushdCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/pwd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub(crate) struct PwdCommand {
allow_symlinks: bool,
}


impl builtins::Command for PwdCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ pub(crate) struct ReadCommand {
variable_names: Vec<String>,
}


impl builtins::Command for ReadCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/return_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pub(crate) struct ReturnCommand {
code: Option<i32>,
}


impl builtins::Command for ReturnCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ pub(crate) struct SetCommand {
positional_args: Vec<String>,
}


impl builtins::Command for SetCommand {
fn takes_plus_options() -> bool {
true
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/shift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pub(crate) struct ShiftCommand {
n: Option<i32>,
}


impl builtins::Command for ShiftCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/shopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ pub(crate) struct ShoptCommand {
options: Vec<String>,
}


impl builtins::Command for ShoptCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ pub(crate) struct TestCommand {
args: Vec<String>,
}


impl builtins::Command for TestCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/trap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pub(crate) struct TrapCommand {
args: Vec<String>,
}


impl builtins::Command for TrapCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/true_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::{builtins, commands};
#[derive(Parser)]
pub(crate) struct TrueCommand {}


impl builtins::Command for TrueCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ enum ResolvedType {
File(PathBuf),
}


impl builtins::Command for TypeCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/umask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ pub(crate) struct UmaskCommand {
mode: Option<String>,
}


impl builtins::Command for UmaskCommand {
async fn execute(
&self,
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/builtins/unalias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub(crate) struct UnaliasCommand {
aliases: Vec<String>,
}


impl builtins::Command for UnaliasCommand {
async fn execute(
&self,
Expand Down
Loading

0 comments on commit 94202e3

Please sign in to comment.