Files
wasmtime/src/commands/config.rs
Alex Crichton 5fe06f7345 Update to clap 3.* (#4082)
* Update to clap 3.0

This commit migrates all CLI commands internally used in this project
from structopt/clap2 to clap 3. The intent here is to ensure that we're
using maintained versions of the dependencies as structopt and clap 2
are less maintained nowadays. Most transitions were pretty
straightforward and mostly dealing with structopt/clap3 differences.

* Fix a number of `cargo deny` errors

This commit fixes a few errors around duplicate dependencies which
arose from the prior update to clap3. This also uses a new feature in
`deny.toml`, `skip-tree`, which allows having a bit more targeted
ignores for skips of duplicate version checks. This showed a few more
locations in Wasmtime itself where we could update some dependencies.
2022-04-28 12:47:12 -05:00

55 lines
1.3 KiB
Rust

//! The module that implements the `wasmtime config` command.
use anyhow::Result;
use clap::Parser;
const CONFIG_NEW_AFTER_HELP: &str =
"If no file path is specified, the system configuration file path will be used.";
/// Controls Wasmtime configuration settings
#[derive(Parser)]
#[clap(name = "config")]
pub struct ConfigCommand {
#[clap(subcommand)]
subcommand: ConfigSubcommand,
}
#[derive(clap::Subcommand)]
enum ConfigSubcommand {
/// Creates a new Wasmtime configuration file
#[clap(after_help = CONFIG_NEW_AFTER_HELP)]
New(ConfigNewCommand),
}
impl ConfigCommand {
/// Executes the command.
pub fn execute(self) -> Result<()> {
match self.subcommand {
ConfigSubcommand::New(c) => c.execute(),
}
}
}
/// Creates a new Wasmtime configuration file
#[derive(Parser)]
#[clap(name = "new", after_help = CONFIG_NEW_AFTER_HELP)]
pub struct ConfigNewCommand {
/// The path of the new configuration file
#[clap(index = 1, value_name = "FILE_PATH")]
path: Option<String>,
}
impl ConfigNewCommand {
/// Executes the command.
pub fn execute(self) -> Result<()> {
let path = wasmtime_cache::create_new_config(self.path.as_ref())?;
println!(
"Successfully created a new configuration file at '{}'.",
path.display()
);
Ok(())
}
}