Skip to content

Commit

Permalink
garden ls: hide commands using "-c" / "--no-commands"
Browse files Browse the repository at this point in the history
  • Loading branch information
davvid committed Dec 26, 2023
1 parent c5640f4 commit 5187f48
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions doc/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

- `garden ls` now displays information about trees, groups, gardens and commands.

- `garden ls -c` hides command details from the output.

## v1.0.0

**Features**
Expand Down
10 changes: 7 additions & 3 deletions src/cmds/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ pub struct ListOptions {
/// Display details for all trees, including missing trees
#[arg(short, long, default_value_t = false)]
all: bool,
/// Do not list commands
#[arg(long, short = 'c', default_value_t = false)]
no_commands: bool,
/// Display worktrees
#[arg(short, long, default_value_t = false)]
worktrees: bool,
Expand All @@ -30,6 +33,7 @@ fn list(app_context: &model::ApplicationContext, options: &ListOptions) -> Resul
let config = app_context.get_root_config();
let display_all = options.all;
let display_worktrees = options.worktrees;
let show_commands = !options.no_commands;
let verbose = app_context.options.verbose;
let mut needs_newline = false;

Expand Down Expand Up @@ -67,7 +71,7 @@ fn list(app_context: &model::ApplicationContext, options: &ListOptions) -> Resul
tree,
display_worktrees,
);
if !tree.commands.is_empty() {
if show_commands && !tree.commands.is_empty() {
display::print_commands(&tree.commands);
}
}
Expand All @@ -89,7 +93,7 @@ fn list(app_context: &model::ApplicationContext, options: &ListOptions) -> Resul
}
display::print_tree(tree, config.tree_branches, verbose, false);
display::print_tree_extended_details(app_context, context, tree, display_worktrees);
if !tree.commands.is_empty() {
if show_commands && !tree.commands.is_empty() {
display::print_commands(&tree.commands);
}
needs_newline = true;
Expand All @@ -106,7 +110,7 @@ fn list(app_context: &model::ApplicationContext, options: &ListOptions) -> Resul
display::print_gardens(&config.gardens);
}

if !config.commands.is_empty() {
if show_commands && !config.commands.is_empty() {
println!();
display::print_commands(&config.commands);
}
Expand Down

0 comments on commit 5187f48

Please sign in to comment.