diff options
author | Dan Prince <dprince@redhat.com> | 2015-08-14 17:20:47 -0400 |
---|---|---|
committer | Dan Prince <dprince@redhat.com> | 2015-08-14 17:23:19 -0400 |
commit | 7aed850aaffe8f22cc95d26ec6d48dc1fc0fd834 (patch) | |
tree | 23ecdd6ea7cd17f4e5e51e7b27bf41663c43a1a7 /os_net_config/cli.py | |
parent | 103b87aa82cfd298b664fe1314e987bd953ec20d (diff) |
Add --detailed-exit-codes
This patch adds a new --detailed-exit-codes option which can
be used to optionally enable the os-net-config CLI to return
exit code 2 if there have been modifications. Detailed
exit codes are useful if you need to trigger subsequent
external actions based whether os-net-config made changes or not.
Change-Id: I8f22fa15335d1276f4e444a6454a24ff486e1495
Diffstat (limited to 'os_net_config/cli.py')
-rw-r--r-- | os_net_config/cli.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/os_net_config/cli.py b/os_net_config/cli.py index c2491a2..c0ac5c4 100644 --- a/os_net_config/cli.py +++ b/os_net_config/cli.py @@ -48,6 +48,13 @@ def parse_opts(argv): parser.add_argument('-r', '--root-dir', metavar='ROOT_DIR', help="""The root directory of the filesystem.""", default='') + parser.add_argument('--detailed-exit-codes', + action='store_true', + help="""Enable detailed exit codes. """ + """If enabled an exit code of '2' means """ + """that files were modified.""" + """Disabled by default.""", + default=False) parser.add_argument( '-d', '--debug', dest="debug", @@ -183,6 +190,10 @@ def main(argv=sys.argv): print("File: %s\n" % location) print(data) print("----") + + if opts.detailed_exit_codes and len(files_changed) > 0: + return 2 + return 0 |