MCPcopy Create free account
hub / github.com/consensus-shipyard/ipc / cli

Function cli

ipc/cli/src/commands/mod.rs:130–167  ·  view source on GitHub ↗

The `cli` method exposed to handle all the cli commands, ideally from main. # Examples Sample usage: ```ignore # to start the daemon with ipc-client daemon ./config/template.toml ``` To register a new command, add the command to ```ignore pub async fn cli() { // ... other code let r = match &args.command { // ... other existing commands Commands::NewCommand => NewCommand::handle(n).await, };

()

Source from the content-addressed store, hash-verified

128/// }
129/// ```
130pub async fn cli() -> anyhow::Result<()> {
131 let global = GlobalOptions::parse();
132 set_current_network(global.global_params.network());
133
134 // parse the arguments
135 let args = IPCAgentCliCommands::parse();
136
137 if let Some(generator) = args.generator {
138 let mut cmd = IPCAgentCliCommands::command();
139 print_completions(generator, &mut cmd);
140 Ok(())
141 } else {
142 let global = &args.global_params;
143 if let Some(c) = &args.command {
144 if !matches!(c, Commands::Node(_)) {
145 default_subscriber();
146 }
147
148 let r = match &c {
149 // Commands::Daemon(args) => LaunchDaemon::handle(global, args).await,
150 Commands::Config(args) => args.handle(global).await,
151 Commands::Subnet(args) => args.handle(global).await,
152 Commands::CrossMsg(args) => args.handle(global).await,
153 Commands::Wallet(args) => args.handle(global).await,
154 Commands::Checkpoint(args) => args.handle(global).await,
155 Commands::Util(args) => args.handle(global).await,
156 Commands::Validator(args) => args.handle(global).await,
157 Commands::Deploy(args) => DeployCommand::handle(global, args).await,
158 Commands::Ui(args) => run_ui_command(global.clone(), args.clone()).await,
159 Commands::Node(args) => args.handle(global).await,
160 };
161
162 r.with_context(|| format!("error processing command {:?}", args.command))
163 } else {
164 Ok(())
165 }
166 }
167}
168
169pub fn default_subscriber() {
170 tracing_subscriber::registry()

Callers 1

mainFunction · 0.85

Calls 8

parseFunction · 0.85
print_completionsFunction · 0.85
default_subscriberFunction · 0.85
run_ui_commandFunction · 0.85
with_contextMethod · 0.80
handleFunction · 0.50
networkMethod · 0.45
handleMethod · 0.45

Tested by

no test coverage detected