use crate::ops::forc_check;
use clap::Parser;
use forc_pkg::source::IPFSNode;
use forc_util::{forc_result_bail, ForcResult};
use sway_core::{BuildTarget, Engines};
forc_util::cli_examples! {
[ Check the current project => forc "check" => r#".*could not find `Forc.toml`.*"# ]
[ Check the current project with a different path => forc "check --path ../tests/" => r#".*could not find `Forc.toml`.*"# ]
[ Check the current project without updating dependencies => forc "check --locked" => r#".*could not find `Forc.toml`.*"# ]
}
#[derive(Debug, Default, Parser)]
#[clap(bin_name = "forc check", version, after_help = help())]
pub struct Command {
#[clap(value_enum, default_value_t=BuildTarget::default(), alias="target")]
pub build_target: BuildTarget,
#[clap(short, long)]
pub path: Option<String>,
#[clap(long = "offline")]
pub offline_mode: bool,
#[clap(long)]
pub locked: bool,
#[clap(long = "terse", short = 't')]
pub terse_mode: bool,
#[clap(long = "disable-tests")]
pub disable_tests: bool,
#[clap(long)]
pub ipfs_node: Option<IPFSNode>,
}
pub(crate) fn exec(command: Command) -> ForcResult<()> {
let engines = Engines::default();
let res = forc_check::check(command, &engines)?;
if res.0.is_none() {
forc_result_bail!("unable to type check");
}
Ok(())
}