From 5059daf8bd59a83f520c14731173ea76ce8b8661 Mon Sep 17 00:00:00 2001 From: Hartmut Goebel Date: Sun, 8 Sep 2019 13:09:15 +0200 Subject: [PATCH] [debops-defaults] If `view` is not available, try less, etc. --- bin/debops-defaults | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/bin/debops-defaults b/bin/debops-defaults index 9dd87fe0a..3e3db4c41 100755 --- a/bin/debops-defaults +++ b/bin/debops-defaults @@ -96,13 +96,22 @@ def main(role_list): config = read_config(project_root) playbooks_path = find_playbookpath(config, project_root, required=True) - # Make sure required commands are present - require_commands('view') - - if sys.stdout.isatty(): + # Check if one of the output commands is present + sys.stdout = io.BytesIO() # suppress error message, if any + for cmd_args in (('view', '+set ft=yaml', '-'), + ('less', '-'), + ('more', '-')): + try: + require_commands(cmd_args[0]) + break + except SystemExit: + # this command was not found + cmd_args = None + sys.stdout = sys.__stdout__ + + if cmd_args and sys.stdout.isatty(): # if script is run as standalone, redirect to view - view = subprocess.Popen(['view', '+set ft=yaml', '-'], - stdin=subprocess.PIPE) + view = subprocess.Popen(cmd_args, stdin=subprocess.PIPE) try: aggregate_defaults(playbooks_path, role_list, view.stdin) except IOError as e: -- 2.21.0 82a6a6dd82e8'/>
path: root/etc/completion/bash
AgeCommit message (Expand)Author
2020-12-04bash completion: Complete file names after '-f' and '-l'....Ludovic Courtès
2020-09-24bash completion: Adjust to new 'guix help' output....Ludovic Courtès
2020-09-21bash completion: Complete file names after 'guix package -p'....Fulbert
2020-09-10bash completion: Restore completion for 'guix system', etc....Ludovic Courtès
2020-06-27bash completion: Complete 'guix environment' properly....Ludovic Courtès
2020-06-04bash completion: Complete sub-commands after 'guix time-machine'....Ludovic Courtès
2020-06-04bash completion: Complete file names after '-p' and '-C'....Ludovic Courtès
2020-02-14guix build: Add '--manifest' option....Marius Bakke
2019-04-29guix package: Add 'install', 'remove', and 'upgrade' aliases....Ludovic Courtès
2018-11-06bash completion: Restore completion of available packages for 'guix build'....Ludovic Courtès
2018-07-03bash completion: Complete files names after 'guix weather -m'....Oleg Pykhalov
2018-07-03bash completion: Complete files names after 'guix build -L'....Oleg Pykhalov
2018-06-16Add guix-daemon Bash completion file....Oleg Pykhalov
2018-02-17bash completion: Complete files names after 'guix package -m'....Oleg Pykhalov
2017-08-22bash completion: Complete files names after 'guix download'....Marius Bakke