Skip to content

Commit 0a09565

Browse files
committed
add args for logging, cmd-type detection
Signed-off-by: Maximilian Deubel <[email protected]>
1 parent e1b0d26 commit 0a09565

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ For the device to respond to AT commands, the firmware on the device must have a
1515
## Command Line Interface
1616

1717
```
18-
usage: nrfcredstore [-h] [--baudrate BAUDRATE] [--timeout TIMEOUT] dev {list,write,delete,deleteall,imei,attoken,generate} ...
18+
usage: nrfcredstore [-h] [--baudrate BAUDRATE] [--timeout TIMEOUT] [--debug] [--cmd-type {at,shell,auto}]
19+
dev {list,write,delete,deleteall,imei,attoken,generate} ...
1920
2021
Manage certificates stored in a cellular modem.
2122
@@ -27,6 +28,9 @@ options:
2728
-h, --help show this help message and exit
2829
--baudrate BAUDRATE Serial baudrate
2930
--timeout TIMEOUT Serial communication timeout in seconds
31+
--debug Enable debug logging
32+
--cmd-type {at,shell,auto}
33+
Command type to use. "at" for AT commands, "shell" for shell commands, "auto" to detect automatically.
3034
3135
subcommands:
3236
{list,write,delete,deleteall,imei,attoken,generate}

src/nrfcredstore/cli.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ def parse_args(in_args):
2525
parser.add_argument('--baudrate', type=int, default=115200, help='Serial baudrate')
2626
parser.add_argument('--timeout', type=int, default=3,
2727
help='Serial communication timeout in seconds')
28+
parser.add_argument('--debug', action='store_true',
29+
help='Enable debug logging')
30+
parser.add_argument('--cmd-type', choices=['at', 'shell', 'auto'], default='auto',
31+
help='Command type to use. "at" for AT commands, "shell" for shell commands, "auto" to detect automatically.')
2832

2933
subparsers = parser.add_subparsers(
3034
title='subcommands', dest='subcommand', help='Certificate related commands'
@@ -127,15 +131,22 @@ def exit_with_msg(exitcode, msg):
127131
exit(exitcode)
128132

129133
def main(args, credstore):
130-
credstore.command_interface.detect_shell_mode()
134+
if args.cmd_type == 'auto':
135+
credstore.command_interface.detect_shell_mode()
136+
elif args.cmd_type == 'shell':
137+
credstore.command_interface.set_shell_mode(True)
131138
credstore.command_interface.enable_error_codes()
132139
exec_cmd(args, credstore)
133140

134141
def run(argv=sys.argv):
135-
logging.basicConfig(level='DEBUG')
136142
args = parse_args(argv[1:])
137143
comms = None
138144

145+
if args.debug:
146+
logging.basicConfig(level='DEBUG')
147+
else:
148+
logging.basicConfig(level='ERROR')
149+
139150
# Use inquirer to find the device
140151
if args.dev == 'auto':
141152
comms = Comms(list_all=True, baudrate=args.baudrate, timeout=args.timeout)

0 commit comments

Comments
 (0)