laforge has uploaded this change for review.
pySim-shell: Add a mode where a pySim-shell cmd can be passed by shell
This adds a new operation mode for pySim-shell, where a single command
can be passed to pySim-shell, which then is executed before pySim-shell
terminates.
Example: ./pySim-shell.py -p0 export --json
Change-Id: I0ed379b23a4b1126006fd8f9e7ba2ba07fb01ada
Closes: OS#6088
---
M pySim-shell.py
1 file changed, 25 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/05/33705/1
diff --git a/pySim-shell.py b/pySim-shell.py
index 213f057..3b56bfd 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -982,6 +982,11 @@
adm_group.add_argument('-A', '--pin-adm-hex', metavar='PIN_ADM1_HEX', dest='pin_adm_hex', default=None,
help='ADM PIN used for provisioning, as hex string (16 characters long)')
+option_parser.add_argument("command", nargs='?',
+ help="A pySim-shell command that would optionally be executed at startup")
+option_parser.add_argument('command_args', nargs=argparse.REMAINDER,
+ help="Optional Arguments for command")
+
if __name__ == '__main__':
@@ -1045,4 +1050,7 @@
except Exception as e:
print(e)
- app.cmdloop()
+ if opts.command:
+ app.onecmd_plus_hooks('{} {}'.format(opts.command, ' '.join(opts.command_args)))
+ else:
+ app.cmdloop()
To view, visit change 33705. To unsubscribe, or for help writing mail filters, visit settings.