1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use crate::ops::forc_init;
use clap::Parser;
use forc_util::ForcResult;

/// Create a new Forc project in an existing directory.
#[derive(Debug, Parser)]
pub struct Command {
    /// The directory in which the forc project will be initialized.
    #[clap(long)]
    pub path: Option<String>,
    /// The default program type, excluding all flags or adding this flag creates a basic contract program.
    #[clap(long)]
    pub contract: bool,
    /// Create a package with a script target (src/main.sw).
    #[clap(long)]
    pub script: bool,
    /// Create a package with a predicate target (src/predicate.rs).
    #[clap(long)]
    pub predicate: bool,
    /// Create a package with a library target (src/lib.sw).
    #[clap(long)]
    pub library: bool,
    /// Adding this flag creates an empty workspace.
    #[clap(long)]
    pub workspace: bool,
    /// Set the package name. Defaults to the directory name
    #[clap(long)]
    pub name: Option<String>,
}

pub(crate) fn exec(command: Command) -> ForcResult<()> {
    forc_init::init(command)?;
    Ok(())
}