wasmtime_cli/commands/
config.rs1use anyhow::Result;
4use clap::{Parser, Subcommand};
5
6const CONFIG_NEW_AFTER_HELP: &str =
7 "If no file path is specified, the system configuration file path will be used.";
8
9#[derive(Parser, PartialEq)]
11pub struct ConfigCommand {
12 #[command(subcommand)]
13 subcommand: ConfigSubcommand,
14}
15
16#[derive(Subcommand, PartialEq)]
17enum ConfigSubcommand {
18 #[command(after_help = CONFIG_NEW_AFTER_HELP)]
20 New(ConfigNewCommand),
21}
22
23impl ConfigCommand {
24 pub fn execute(self) -> Result<()> {
26 match self.subcommand {
27 ConfigSubcommand::New(c) => c.execute(),
28 }
29 }
30}
31
32#[derive(Parser, PartialEq)]
34pub struct ConfigNewCommand {
35 #[arg(index = 1, value_name = "FILE_PATH")]
37 path: Option<String>,
38}
39
40impl ConfigNewCommand {
41 pub fn execute(self) -> Result<()> {
43 let path = wasmtime_cache::create_new_config(self.path.as_ref())?;
44
45 println!(
46 "Successfully created a new configuration file at '{}'.",
47 path.display()
48 );
49
50 Ok(())
51 }
52}