Skip to content

Commit

Permalink
feat(forge/install): take root flag (gakonst#580)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrencev authored Jan 25, 2022
1 parent 8ccfe49 commit 5516d50
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions cli/src/cmd/install.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//! Create command
use std::path::PathBuf;

use crate::{cmd::Cmd, opts::forge::Dependency, utils::p_println};
use ansi_term::Colour;
use clap::Parser;
use clap::{Parser, ValueHint};
use foundry_config::find_project_root_path;
use std::{
path::Path,
Expand All @@ -16,13 +17,21 @@ pub struct InstallArgs {
dependencies: Vec<Dependency>,
#[clap(flatten)]
opts: DependencyInstallOpts,
#[clap(
help = "the project's root path. By default, this is the root directory of the current Git repository or the current working directory if it is not part of a Git repository",
long,
value_hint = ValueHint::DirPath
)]
pub root: Option<PathBuf>,
}

impl Cmd for InstallArgs {
type Output = ();

fn run(self) -> eyre::Result<Self::Output> {
install(find_project_root_path()?, self.dependencies, self.opts)
let InstallArgs { root, .. } = self;
let root = root.unwrap_or_else(|| find_project_root_path().unwrap());
install(root, self.dependencies, self.opts)
}
}

Expand Down

0 comments on commit 5516d50

Please sign in to comment.