aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRagnis Armus <ragnis@armus.ee>2019-12-03 20:25:34 +0200
committerRagnis Armus <ragnis@armus.ee>2019-12-03 20:25:34 +0200
commit4696e729c1b712b7a060f60b98454663bb180d35 (patch)
treefbd26c9c00bf37bb3e12e7323353fdc10e44bb84
parentb9da8259e79e8888dc81cf2da1013b1ee7f4eec7 (diff)
Add verbose mode
-rwxr-xr-xggoto19
1 files changed, 16 insertions, 3 deletions
diff --git a/ggoto b/ggoto
index 130d826..1948eb7 100755
--- a/ggoto
+++ b/ggoto
@@ -6,6 +6,9 @@ import subprocess
import sys
+exec_verbose = False
+
+
def get_file_sha1sum(filename):
hash = hashlib.sha1()
@@ -49,6 +52,7 @@ def parse_args(argv):
rv = {
'force': False,
'help': False,
+ 'verbose': False,
}
for i, arg in enumerate(argv):
@@ -56,6 +60,8 @@ def parse_args(argv):
rv['force'] = True
elif arg == '-h' or arg == '--help':
rv['help'] = True
+ elif arg == '-v':
+ rv['verbose'] = True
elif 'ref' not in rv:
rv['ref'] = arg
else:
@@ -74,9 +80,13 @@ def parse_git_ref(ref):
def exec(args):
- cp = subprocess.run(args,
- stdout=subprocess.DEVNULL,
- stderr=subprocess.DEVNULL)
+ out = subprocess.DEVNULL
+
+ if exec_verbose:
+ out = subprocess.PIPE
+ print('$ ' + ' '.join(args))
+
+ cp = subprocess.run(args, stdout=out, stderr=out)
cp.check_returncode()
return cp
@@ -145,6 +155,9 @@ if __name__ == '__main__':
'package-lock.json',
])
+ if args['verbose']:
+ exec_verbose = True
+
if 'ref' in args:
(remote, rev) = parse_git_ref(args['ref'])
else: