Skip to content

Commit

Permalink
feat: allow listing from specific handle (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardoRodriguesF committed May 19, 2024
1 parent 3e544fa commit c7c5263
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added handle argument for `ls` to allow listing a specific handle tree. ([#44](https://github.com/EduardoRodriguesF/quartz/issues/44))
- `quartz use -` to switch to the last used handle. ([#45](https://github.com/EduardoRodriguesF/quartz/issues/45) by [@GabrielBrandao1618](https://github.com/GabrielBrandao1618))
- Content-type hints `body edit` into correct extension. ([#46](https://github.com/EduardoRodriguesF/quartz/issues/46))

Expand Down
4 changes: 2 additions & 2 deletions doc/quartz.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ The endpoint *local/users* will use *http://localhost:8080/users* when sending a
**\-\-use**
: Immediately switches to this handle after creating it.

**ls**, **list**
: List all available handles.
**ls**, **list** [*HANDLE*]
: List handles.

The options are as follows:

Expand Down
10 changes: 9 additions & 1 deletion src/action/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ fn print_outputs(list: Vec<Output>) {

#[derive(clap::Args, Debug)]
pub struct Args {
/// See the children of a specific handle
handle: Option<String>,

/// Set a limit for how deep the listing goes in sub-handles
#[arg(long, value_name = "N")]
depth: Option<usize>,
Expand All @@ -117,7 +120,12 @@ pub fn cmd(ctx: &Ctx, args: Args) {
let active_handle = EndpointHandle::from_state(ctx);
let mut output_list: Vec<Output> = vec![];

let tree = EndpointHandle::QUARTZ.tree(ctx);
let tree = if let Some(handle) = args.handle {
EndpointHandle::from(handle).tree(ctx)
} else {
EndpointHandle::QUARTZ.tree(ctx)
};

let mut queue = vec![&tree.root];

while let Some(node) = queue.pop() {
Expand Down

0 comments on commit c7c5263

Please sign in to comment.