use anyhow::Result;
use contract_build::{
CrateMetadata,
ManifestPath,
VerbosityFlags,
lint,
};
use std::path::PathBuf;
#[derive(Debug, clap::Args)]
#[clap(name = "lint")]
pub struct LintCommand {
#[clap(long, value_parser)]
manifest_path: Option<PathBuf>,
#[clap(flatten)]
verbosity: VerbosityFlags,
#[clap(long)]
extra_lints: bool,
}
impl LintCommand {
pub fn run(&self) -> Result<()> {
let manifest_path = ManifestPath::try_from(self.manifest_path.as_ref())?;
let crate_metadata = CrateMetadata::collect(&manifest_path)?;
let verbosity = TryFrom::<&VerbosityFlags>::try_from(&self.verbosity)?;
lint(self.extra_lints, &crate_metadata, &verbosity)
}
}