Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose more tree internals, add --dir #3

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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