Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/src/commands/config.rs
1690 views
1
//! The module that implements the `wasmtime config` command.
2
3
use anyhow::Result;
4
use clap::{Parser, Subcommand};
5
6
const CONFIG_NEW_AFTER_HELP: &str =
7
"If no file path is specified, the system configuration file path will be used.";
8
9
/// Controls Wasmtime configuration settings
10
#[derive(Parser, PartialEq)]
11
pub struct ConfigCommand {
12
#[command(subcommand)]
13
subcommand: ConfigSubcommand,
14
}
15
16
#[derive(Subcommand, PartialEq)]
17
enum ConfigSubcommand {
18
/// Creates a new Wasmtime configuration file
19
#[command(after_help = CONFIG_NEW_AFTER_HELP)]
20
New(ConfigNewCommand),
21
}
22
23
impl ConfigCommand {
24
/// Executes the command.
25
pub fn execute(self) -> Result<()> {
26
match self.subcommand {
27
ConfigSubcommand::New(c) => c.execute(),
28
}
29
}
30
}
31
32
/// Creates a new Wasmtime configuration file
33
#[derive(Parser, PartialEq)]
34
pub struct ConfigNewCommand {
35
/// The path of the new configuration file
36
#[arg(index = 1, value_name = "FILE_PATH")]
37
path: Option<String>,
38
}
39
40
impl ConfigNewCommand {
41
/// Executes the command.
42
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
}
53
54