diff options
author | John Estabrook <jestabro@vyos.io> | 2022-02-21 14:03:22 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-21 14:03:22 -0600 |
commit | d59fac9148ccbe677716baebac813c45b84de712 (patch) | |
tree | 5fd228cf341163e689692d26effa0885090d86fb /src/op_mode/show_version.py | |
parent | 36a8c636d6d91550237bfa19b12de949319bc692 (diff) | |
parent | a3b7e985911eeaccac4fa229563b78c5a64e7e90 (diff) | |
download | vyos-1x-d59fac9148ccbe677716baebac813c45b84de712.tar.gz vyos-1x-d59fac9148ccbe677716baebac813c45b84de712.zip |
Merge pull request #1233 from dmbaturin/structured-op-mode
T2719: initial batch of standardized structure op mode scripts
Diffstat (limited to 'src/op_mode/show_version.py')
-rwxr-xr-x | src/op_mode/show_version.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/op_mode/show_version.py b/src/op_mode/show_version.py index 7962e1e7b..b82ab6eca 100755 --- a/src/op_mode/show_version.py +++ b/src/op_mode/show_version.py @@ -26,10 +26,6 @@ from jinja2 import Template from sys import exit from vyos.util import call -parser = argparse.ArgumentParser() -parser.add_argument("-f", "--funny", action="store_true", help="Add something funny to the output") -parser.add_argument("-j", "--json", action="store_true", help="Produce JSON output") - version_output_tmpl = """ Version: VyOS {{version}} Release train: {{release_train}} @@ -51,7 +47,20 @@ Hardware UUID: {{hardware_uuid}} Copyright: VyOS maintainers and contributors """ +def get_raw_data(): + version_data = vyos.version.get_full_version_data() + return version_data + +def get_formatted_output(): + version_data = get_raw_data() + tmpl = Template(version_output_tmpl) + return tmpl.render(version_data) + if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument("-f", "--funny", action="store_true", help="Add something funny to the output") + parser.add_argument("-j", "--json", action="store_true", help="Produce JSON output") + args = parser.parse_args() version_data = vyos.version.get_full_version_data() @@ -60,9 +69,8 @@ if __name__ == '__main__': import json print(json.dumps(version_data)) exit(0) - - tmpl = Template(version_output_tmpl) - print(tmpl.render(version_data)) + else: + print(get_formatted_output()) if args.funny: print(vyos.limericks.get_random()) |