Skip to content

Commit

Permalink
Merge pull request #3 from simonbuchan/tree-api
Browse files Browse the repository at this point in the history
feat: expose more tree internals, add --dir
  • Loading branch information
simonbuchan authored Sep 24, 2024
2 parents 8c065c0 + 21b0865 commit 132123d
Show file tree
Hide file tree
Showing 5 changed files with 211 additions and 95 deletions.
9 changes: 5 additions & 4 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ serde = { version = "1.0.206", features = ["derive"] }
serde_json = "1.0.124"
serde_yaml = "0.9.34"
anyhow = "1.0.86"
thiserror = "1.0.64"

[lints.rust]
rust_2018_idioms = { level = "warn", priority = -1 }
Expand Down
5 changes: 2 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@

use anyhow::{bail, Context as _, Result};

mod tree;

pub use tree::print_tree;
/// `pnpm-extra tree` implementation details.
pub mod tree;

/// Parse and return the content of pnpm-workspace.yaml as a serde_yaml::Mapping.
///
Expand Down
11 changes: 9 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@

use anyhow::Result;
use clap::Parser;
use std::path::PathBuf;

#[derive(Parser)]
enum Args {
/// better pnpm why, modelled on cargo tree -i
Tree {
#[clap(name = "name")]
/// Package name to show the tree for
name: String,

#[clap(short, long, default_value = ".")]
/// Workspace directory
dir: PathBuf,
},

#[clap(subcommand)]
Expand All @@ -19,8 +25,9 @@ mod catalog;

fn main() -> Result<()> {
match Args::parse() {
Args::Tree { name } => {
pnpm_extra::print_tree(&name)?;
Args::Tree { name, dir } => {
let dir = std::path::absolute(dir)?;
pnpm_extra::tree::print_tree(&dir, &name)?;
Ok(())
}
Args::Catalog(args) => {
Expand Down
Loading

0 comments on commit 132123d

Please sign in to comment.