gnu: Add kafs-client
[jackhill/guix/guix.git] / gnu / packages / patches / debops-debops-defaults-fall-back-to-less.patch
1 From 5059daf8bd59a83f520c14731173ea76ce8b8661 Mon Sep 17 00:00:00 2001
2 From: Hartmut Goebel <h.goebel@crazy-compilers.com>
3 Date: Sun, 8 Sep 2019 13:09:15 +0200
4 Subject: [PATCH] [debops-defaults] If `view` is not available, try less, etc.
5
6 ---
7 bin/debops-defaults | 21 +++++++++++++++------
8 1 file changed, 15 insertions(+), 6 deletions(-)
9
10 diff --git a/bin/debops-defaults b/bin/debops-defaults
11 index 9dd87fe0a..3e3db4c41 100755
12 --- a/bin/debops-defaults
13 +++ b/bin/debops-defaults
14 @@ -96,13 +96,22 @@ def main(role_list):
15 config = read_config(project_root)
16 playbooks_path = find_playbookpath(config, project_root, required=True)
17
18 - # Make sure required commands are present
19 - require_commands('view')
20 -
21 - if sys.stdout.isatty():
22 + # Check if one of the output commands is present
23 + sys.stdout = io.BytesIO() # suppress error message, if any
24 + for cmd_args in (('view', '+set ft=yaml', '-'),
25 + ('less', '-'),
26 + ('more', '-')):
27 + try:
28 + require_commands(cmd_args[0])
29 + break
30 + except SystemExit:
31 + # this command was not found
32 + cmd_args = None
33 + sys.stdout = sys.__stdout__
34 +
35 + if cmd_args and sys.stdout.isatty():
36 # if script is run as standalone, redirect to view
37 - view = subprocess.Popen(['view', '+set ft=yaml', '-'],
38 - stdin=subprocess.PIPE)
39 + view = subprocess.Popen(cmd_args, stdin=subprocess.PIPE)
40 try:
41 aggregate_defaults(playbooks_path, role_list, view.stdin)
42 except IOError as e:
43 --
44 2.21.0
45