Skip to content

Commit 804a4bc

Browse files
committed
flux-queue: add -q, --queue option to list subcommand
Problem: The flux-queue(1) `list` subcommand doesn't support a `-q, --queue` option like most other Flux commands. Add support for this option.
1 parent d5ba0e7 commit 804a4bc

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/cmd/flux-queue.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import sys
1717

1818
import flux
19-
from flux.util import AltField, UtilConfig, parse_fsd
19+
from flux.util import AltField, FilterActionSetUpdate, UtilConfig, parse_fsd
2020

2121

2222
def print_enable_status(name, status):
@@ -342,10 +342,22 @@ def list(args):
342342
fmt = FluxQueueConfig("list").load().get_format_string(args.format)
343343
formatter = flux.util.OutputFormat(fmt, headings=headings)
344344

345+
# Build queue_config from args.queue, or config["queue"] if --queue
346+
# was unused:
347+
queue_config = {}
348+
if args.queue:
349+
for queue in args.queue:
350+
try:
351+
queue_config[queue] = config["queues"][queue]
352+
except KeyError:
353+
raise ValueError(f"No such queue: {queue}")
354+
elif config and "queues" in config:
355+
queue_config = config["queues"]
356+
345357
queues = []
346358
if config and "queues" in config:
347-
status = fetch_all_queue_status(handle, config["queues"].keys())
348-
for key, value in config["queues"].items():
359+
status = fetch_all_queue_status(handle, queue_config.keys())
360+
for key, value in queue_config.items():
349361
queues.append(
350362
QueueInfo(key, config, status[key]["enable"], status[key]["start"])
351363
)
@@ -511,6 +523,14 @@ def main():
511523
list_parser = subparsers.add_parser(
512524
"list", formatter_class=flux.util.help_formatter()
513525
)
526+
list_parser.add_argument(
527+
"-q",
528+
"--queue",
529+
action=FilterActionSetUpdate,
530+
default=set(),
531+
metavar="QUEUE,...",
532+
help="Include only specified queues in output",
533+
)
514534
list_parser.add_argument(
515535
"-o",
516536
"--format",

0 commit comments

Comments
 (0)