forc/cli/commands/
init.rs1use crate::ops::forc_init;
2use clap::Parser;
3use forc_util::ForcResult;
4
5forc_util::cli_examples! {
6 crate::cli::Opt {
7 [Initialize a new Forc project => "forc init --path <PATH>"]
8 [Initialize a new Forc project as workspace => "forc init --path <PATH> --workspace"]
9 [Initialize a new Forc project with a predicate => "forc init --path <PATH> --predicate"]
10 [Initialize a new Forc library project => "forc init --path <PATH> --library"]
11 }
12}
13
14#[derive(Debug, Parser)]
16#[clap(bin_name = "forc init", version, after_help = help())]
17pub struct Command {
18 #[clap(long)]
20 pub path: Option<String>,
21 #[clap(long)]
23 pub contract: bool,
24 #[clap(long)]
26 pub script: bool,
27 #[clap(long)]
29 pub predicate: bool,
30 #[clap(long)]
32 pub library: bool,
33 #[clap(long)]
35 pub workspace: bool,
36 #[clap(long)]
38 pub name: Option<String>,
39}
40
41pub(crate) fn exec(command: Command) -> ForcResult<()> {
42 forc_init::init(command)?;
43 Ok(())
44}