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
This commit is contained in:
Harald Welte 2023-07-11 21:17:55 +02:00
parent 531894d386
commit 38306dfc04
1 changed files with 9 additions and 1 deletions

View File

@ -982,6 +982,11 @@ adm_group.add_argument('-a', '--pin-adm', metavar='PIN_ADM1', dest='pin_adm', de
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 @@ if __name__ == '__main__':
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()