Skip to content

Commit

Permalink
cli: in dry-run send the list of hosts to stdout
Browse files Browse the repository at this point in the history
* To simplify the usage from additional tools of the generated list of
  hosts when not executing commands (dry-run mode), send the list to
  stdout while the rest of the output is sent to stderr.
* In conjunction with the -n/--no-color output it should allow for an
  easy piping into additional tools using:

  cumin -n QUERY 2> /dev/null

Bug: T212783
Change-Id: I689fd8a5d639571deda958d403d27a997752e691
  • Loading branch information
volans- committed Sep 10, 2020
1 parent b715b6c commit 6d16ec2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cumin/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,15 @@ def get_hosts(args, config):
return hosts

stderr('{num} hosts will be targeted:'.format(num=len(hosts)))
stderr(Colored.cyan(cumin.nodeset_fromlist(hosts)))
# The list is sent to stdout or stderr based on the dry_run mode

if args.dry_run:
tqdm.write(Colored.cyan(cumin.nodeset_fromlist(hosts)))
stderr('DRY-RUN mode enabled, aborting')
return []

stderr(Colored.cyan(cumin.nodeset_fromlist(hosts)))

if args.force:
stderr('FORCE mode enabled, continuing without confirmation')
return hosts
Expand Down

0 comments on commit 6d16ec2

Please sign in to comment.