rustfs_cli/commands/
mod.rs1use clap::{Parser, Subcommand};
8
9use crate::exit_code::ExitCode;
10use crate::output::OutputConfig;
11
12mod alias;
13mod cat;
14mod completions;
15pub mod cp;
16pub mod diff;
17mod find;
18mod head;
19mod ls;
20mod mb;
21mod mirror;
22mod mv;
23mod pipe;
24mod rb;
25mod rm;
26mod share;
27mod stat;
28mod tag;
29mod tree;
30mod version;
31
32#[derive(Parser, Debug)]
37#[command(name = "rc")]
38#[command(author, version, about, long_about = None)]
39#[command(propagate_version = true)]
40pub struct Cli {
41 #[arg(long, global = true, default_value = "false")]
43 pub json: bool,
44
45 #[arg(long, global = true, default_value = "false")]
47 pub no_color: bool,
48
49 #[arg(long, global = true, default_value = "false")]
51 pub no_progress: bool,
52
53 #[arg(short, long, global = true, default_value = "false")]
55 pub quiet: bool,
56
57 #[arg(long, global = true, default_value = "false")]
59 pub debug: bool,
60
61 #[command(subcommand)]
62 pub command: Commands,
63}
64
65#[derive(Subcommand, Debug)]
66pub enum Commands {
67 #[command(subcommand)]
69 Alias(alias::AliasCommands),
70
71 Ls(ls::LsArgs),
74
75 Mb(mb::MbArgs),
77
78 Rb(rb::RbArgs),
80
81 Cat(cat::CatArgs),
83
84 Head(head::HeadArgs),
86
87 Stat(stat::StatArgs),
89
90 Cp(cp::CpArgs),
93
94 Mv(mv::MvArgs),
96
97 Rm(rm::RmArgs),
99
100 Pipe(pipe::PipeArgs),
102
103 Find(find::FindArgs),
106
107 Diff(diff::DiffArgs),
109
110 Mirror(mirror::MirrorArgs),
112
113 Tree(tree::TreeArgs),
115
116 Share(share::ShareArgs),
118
119 #[command(subcommand)]
122 Version(version::VersionCommands),
123
124 #[command(subcommand)]
126 Tag(tag::TagCommands),
127
128 Completions(completions::CompletionsArgs),
131 }
138
139pub async fn execute(cli: Cli) -> ExitCode {
141 let output_config = OutputConfig {
142 json: cli.json,
143 no_color: cli.no_color,
144 no_progress: cli.no_progress,
145 quiet: cli.quiet,
146 };
147
148 match cli.command {
149 Commands::Alias(cmd) => alias::execute(cmd, output_config).await,
150 Commands::Ls(args) => ls::execute(args, output_config).await,
151 Commands::Mb(args) => mb::execute(args, output_config).await,
152 Commands::Rb(args) => rb::execute(args, output_config).await,
153 Commands::Cat(args) => cat::execute(args, output_config).await,
154 Commands::Head(args) => head::execute(args, output_config).await,
155 Commands::Stat(args) => stat::execute(args, output_config).await,
156 Commands::Cp(args) => cp::execute(args, output_config).await,
157 Commands::Mv(args) => mv::execute(args, output_config).await,
158 Commands::Rm(args) => rm::execute(args, output_config).await,
159 Commands::Pipe(args) => pipe::execute(args, output_config).await,
160 Commands::Find(args) => find::execute(args, output_config).await,
161 Commands::Diff(args) => diff::execute(args, output_config).await,
162 Commands::Mirror(args) => mirror::execute(args, output_config).await,
163 Commands::Tree(args) => tree::execute(args, output_config).await,
164 Commands::Share(args) => share::execute(args, output_config).await,
165 Commands::Version(cmd) => {
166 version::execute(version::VersionArgs { command: cmd }, output_config).await
167 }
168 Commands::Tag(cmd) => tag::execute(tag::TagArgs { command: cmd }, output_config).await,
169 Commands::Completions(args) => completions::execute(args),
170 }
171}