Skip to content

Commit

Permalink
feat(forge): add tree command (#771)
Browse files Browse the repository at this point in the history
* feat(forge): add tree command

* bump ethers

* chore: bump ethers

gakonst/ethers-rs#999

Co-authored-by: Georgios Konstantopoulos <[email protected]>
  • Loading branch information
mattsse and gakonst authored Mar 9, 2022
1 parent 8af5125 commit 4b3a729
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 15 deletions.
28 changes: 14 additions & 14 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions cli/src/cmd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub mod remappings;
pub mod run;
pub mod snapshot;
pub mod test;
pub mod tree;
pub mod verify;
pub mod watch;

Expand Down
34 changes: 34 additions & 0 deletions cli/src/cmd/tree.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//! tree command
use crate::cmd::{build::BuildArgs, Cmd};
use clap::Parser;
use ethers::solc::Graph;
use foundry_config::Config;

foundry_config::impl_figment_convert!(TreeArgs, opts);
use ethers::solc::resolver::{Charset, TreeOptions};

/// Command to display the project's dependency tree
#[derive(Debug, Clone, Parser)]
pub struct TreeArgs {
// TODO extract path related args from BuildArgs
#[clap(flatten)]
opts: BuildArgs,
#[clap(help = "Do not de-duplicate (repeats all shared dependencies)", long)]
no_dedupe: bool,
#[clap(help = "Character set to use in output: utf8, ascii", default_value = "utf8", long)]
charset: Charset,
}

impl Cmd for TreeArgs {
type Output = ();

fn run(self) -> eyre::Result<Self::Output> {
let config: Config = From::from(&self);
let graph = Graph::resolve(&config.project_paths())?;
let opts = TreeOptions { charset: self.charset, no_dedupe: self.no_dedupe };
graph.print_with_options(opts);

Ok(())
}
}
3 changes: 3 additions & 0 deletions cli/src/forge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ fn main() -> eyre::Result<()> {
Subcommands::Flatten(cmd) => {
cmd.run()?;
}
Subcommands::Tree(cmd) => {
cmd.run()?;
}
}

Ok(())
Expand Down
4 changes: 3 additions & 1 deletion cli/src/opts/forge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::cmd::{
install::InstallArgs,
remappings::RemappingArgs,
run::RunArgs,
snapshot, test,
snapshot, test, tree,
verify::{VerifyArgs, VerifyCheckArgs},
};
use serde::Serialize;
Expand Down Expand Up @@ -116,6 +116,8 @@ pub enum Subcommands {
Flatten(flatten::FlattenArgs),
// #[clap(about = "formats Solidity source files")]
// Fmt(FmtArgs),
#[clap(about = "Display a tree visualization of the project's dependency graph")]
Tree(tree::TreeArgs),
}

// A set of solc compiler settings that can be set via command line arguments, which are intended
Expand Down

0 comments on commit 4b3a729

Please sign in to comment.