Unverified Commit fcc6c43b authored by Andrew Jones's avatar Andrew Jones Committed by GitHub
Browse files

Use `ArgEnum` for `BuildArtifacts` (#499)

* Use `clap::ArgEnum` for `BuildArtifacts`

* Remove from-str impl

* Update docs for check-only

* Remove println!
parent 4d0d37d1
Pipeline #187643 passed with stages
in 8 minutes and 22 seconds
......@@ -83,12 +83,10 @@ pub struct BuildCommand {
///
/// - `code-only`: Only the Wasm is created, generation of metadata and a bundled
/// `<name>.contract` file is skipped.
#[clap(
long = "generate",
default_value = "all",
value_name = "all | code-only",
verbatim_doc_comment
)]
///
/// - `check-only`: No artifacts produced: runs the `cargo check` command for the Wasm target,
/// only checks for compilation errors.
#[clap(long = "generate", arg_enum, default_value = "all")]
build_artifact: BuildArtifacts,
#[clap(flatten)]
verbosity: VerbosityFlags,
......
......@@ -209,15 +209,19 @@ impl TryFrom<&UnstableOptions> for UnstableFlags {
}
/// Describes which artifacts to generate
#[derive(Copy, Clone, Eq, PartialEq, Debug, Subcommand, serde::Serialize)]
#[derive(Copy, Clone, Eq, PartialEq, Debug, clap::ArgEnum, serde::Serialize)]
#[clap(name = "build-artifacts")]
pub enum BuildArtifacts {
/// Generate the Wasm, the metadata and a bundled `<name>.contract` file
#[clap(name = "all")]
All,
/// Only the Wasm is created, generation of metadata and a bundled `<name>.contract` file is skipped
/// Only the Wasm is created, generation of metadata and a bundled `<name>.contract` file is
/// skipped
#[clap(name = "code-only")]
CodeOnly,
/// No artifacts produced: runs the `cargo check` command for the Wasm target, only checks for
/// compilation errors.
#[clap(name = "check-only")]
CheckOnly,
}
......@@ -233,17 +237,6 @@ impl BuildArtifacts {
}
}
impl std::str::FromStr for BuildArtifacts {
type Err = String;
fn from_str(artifact: &str) -> Result<Self, Self::Err> {
match artifact {
"all" => Ok(BuildArtifacts::All),
"code-only" => Ok(BuildArtifacts::CodeOnly),
_ => Err("Could not parse build artifact".to_string()),
}
}
}
impl Default for BuildArtifacts {
fn default() -> Self {
BuildArtifacts::All
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment