File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,20 +17,25 @@ sudo snap install xjs
1717
1818## ⌨️ Usage
1919
20- With yaml:
20+ Read from a file ( yaml or json) :
2121
2222``` bash
2323juju status --format yaml > juju-status.yaml
2424xjs juju-status.yaml
2525```
2626
27- With json:
28-
2927``` bash
3028juju status --format json > juju-status.json
3129xjs juju-status.json
3230```
3331
32+ Pipe stdin directly:
33+
34+ ``` bash
35+ juju status --format yaml | xjs --unwanted
36+ juju status --format json | xjs --show-units
37+ ```
38+
3439Options:
3540
3641``` bash
Original file line number Diff line number Diff line change @@ -612,8 +612,8 @@ def filter_results(
612612 help = "Show only units with unwanted workload or agent status" ,
613613)
614614@click .argument (
615- "statusfiles" , required = True , type = click .File ("r" ),
616- nargs = - 1 , metavar = "< status files> " ,
615+ "statusfiles" , required = False , type = click .File ("r" ),
616+ nargs = - 1 , metavar = "[ status files] " ,
617617)
618618def main (
619619 statusfiles : tuple [TextIO , ...],
@@ -637,6 +637,16 @@ def main(
637637 agent_status : str ,
638638 unwanted : bool ,
639639) -> None :
640+ if not statusfiles :
641+ if sys .stdin .isatty ():
642+ console = Console ()
643+ console .print (
644+ "[red]Error: no status files provided"
645+ " and no data piped to stdin[/red]" ,
646+ )
647+ sys .exit (1 )
648+ statusfiles = (sys .stdin ,)
649+
640650 color = not no_color
641651 controllers : dict [str , Controller ] = {}
642652 for statusfile in statusfiles :
You can’t perform that action at this time.
0 commit comments