Mark template as a value_enum

This commit is contained in:
Michael-F-Bryan
2022-12-15 15:42:49 +08:00
parent 80c05e99e7
commit 3da744bf1c

View File

@@ -4,7 +4,6 @@ use clap::Parser;
use std::collections::HashMap; use std::collections::HashMap;
use std::path::Path; use std::path::Path;
use std::path::PathBuf; use std::path::PathBuf;
use std::str::FromStr;
static NOTE: &str = static NOTE: &str =
"# See more keys and definitions at https://docs.wasmer.io/ecosystem/wapm/manifest"; "# See more keys and definitions at https://docs.wasmer.io/ecosystem/wapm/manifest";
@@ -39,8 +38,8 @@ pub struct Init {
/// If the `manifest-path` is a Cargo.toml, use that file to initialize the wapm.toml /// If the `manifest-path` is a Cargo.toml, use that file to initialize the wapm.toml
#[clap(long)] #[clap(long)]
pub manifest_path: Option<PathBuf>, pub manifest_path: Option<PathBuf>,
/// Add default dependencies for common packages (currently supported: `python`, `js`) /// Add default dependencies for common packages
#[clap(long)] #[clap(long, value_enum)]
pub template: Option<Template>, pub template: Option<Template>,
/// Include file paths into the target container filesystem /// Include file paths into the target container filesystem
#[clap(long)] #[clap(long)]
@@ -60,17 +59,6 @@ pub enum Template {
Js, Js,
} }
impl FromStr for Template {
type Err = anyhow::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"python" => Ok(Self::Python),
"js" => Ok(Self::Js),
_ => Err(anyhow::anyhow!("expected \"python\" or \"js\"")),
}
}
}
#[derive(Debug, PartialEq, Copy, Clone)] #[derive(Debug, PartialEq, Copy, Clone)]
enum BinOrLib { enum BinOrLib {
Bin, Bin,