Skip to content

Commit

Permalink
Forc init project from template (#836)
Browse files Browse the repository at this point in the history
* adding forc init template code

* cargo fmt

* remove local path template functionality

* clean up help formatting

* rebase onto master

* remove ability to use GitHub URLs as templates

* remove reference

* added Cargo.lock

* change template help to const
  • Loading branch information
JoshuaBatty committed Mar 8, 2022
1 parent 46a62d7 commit 15f20d5
Show file tree
Hide file tree
Showing 8 changed files with 336 additions and 19 deletions.
36 changes: 35 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions forc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ description = "Fuel Orchestrator."
annotate-snippets = { version = "0.9", features = ["color"] }
ansi_term = "0.12"
anyhow = "1.0.41"
clap = { version = "3.1.2", features = ["env", "derive"] }
clap = { version = "3.1", features = ["env", "derive"] }
clap_complete = "3.1"
dirs = "3.0.2"
fuel-asm = "0.2"
Expand All @@ -39,9 +39,10 @@ term-table = "1.3"
termcolor = "1.1"
tokio = { version = "1.8.0", features = ["macros", "rt-multi-thread", "process"] }
toml = "0.5"
toml_edit = "0.13"
unicode-xid = "0.2.2"
ureq = "2.4"
url = "2"
ureq = { version = "2.4", features = ["json"] }
url = "2.2"
uwuify = { version = "^0.2", optional = true }
warp = "0.3"
whoami = "1.1"
Expand Down
17 changes: 13 additions & 4 deletions forc/src/cli/commands/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,22 @@ use crate::ops::forc_init;
use anyhow::Result;
use clap::Parser;

const TEMPLATE_HELP: &str = r#"Initialize a new project from a template.
Example Templates:
- counter"#;

/// Create a new Forc project.
#[derive(Debug, Parser)]
pub(crate) struct Command {
project_name: String,
pub struct Command {
/// Initialize a new project from a template
#[clap(short, long, help = TEMPLATE_HELP)]
pub template: Option<String>,
/// The name of your project
pub project_name: String,
}

pub(crate) fn exec(command: Command) -> Result<()> {
let project_name = command.project_name;
forc_init::init_new_project(project_name).map_err(|e| e)
forc_init::init(command)?;
Ok(())
}
2 changes: 1 addition & 1 deletion forc/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub use completions::Command as CompletionsCommand;
pub use deploy::Command as DeployCommand;
pub use explorer::Command as ExplorerCommand;
pub use format::Command as FormatCommand;
use init::Command as InitCommand;
pub use init::Command as InitCommand;
pub use json_abi::Command as JsonAbiCommand;
use lsp::Command as LspCommand;
use parse_bytecode::Command as ParseBytecodeCommand;
Expand Down

0 comments on commit 15f20d5

Please sign in to comment.