From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH v2 5/5] bbremote: Print usage when no command is given
Date: Thu, 8 Sep 2022 11:30:05 +0200 [thread overview]
Message-ID: <20220908093005.3035259-6-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20220908093005.3035259-1-s.hauer@pengutronix.de>
Instead of dumping a backtrace, print usage information when no
subcommand is given.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
Notes:
Changes since v1:
- new patch
scripts/remote/main.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/scripts/remote/main.py b/scripts/remote/main.py
index 2f3ce370ae..5aa176fdc4 100644
--- a/scripts/remote/main.py
+++ b/scripts/remote/main.py
@@ -206,6 +206,7 @@ parser.add_argument('--port', type=str, default=os.environ.get('BBREMOTE_PORT',
parser.add_argument('--baudrate', type=int, default=os.environ.get('BBREMOTE_BAUDRATE', 115200))
parser.add_argument('--export', type=str, default=os.environ.get('BBREMOTE_EXPORT', None))
parser.add_argument('-w', '--wait', action='count', default=0)
+parser.set_defaults(func=None)
subparsers = parser.add_subparsers(help='sub-command help')
parser_run = subparsers.add_parser('run', help="run a barebox command")
@@ -277,6 +278,11 @@ parser_console.set_defaults(func=handle_console)
args = parser.parse_args()
logging.basicConfig(level=VERBOSITY[args.verbose],
format='%(levelname)-8s %(module)-8s %(funcName)-16s %(message)s')
+
+if args.func is None:
+ parser.print_help()
+ exit(1)
+
try:
res = args.func(args)
exit(res)
--
2.30.2
prev parent reply other threads:[~2022-09-08 9:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-08 9:30 [PATCH v2 0/5] bbremote: Convert to python3 Sascha Hauer
2022-09-08 9:30 ` [PATCH v2 1/5] remove local pyserial Sascha Hauer
2022-09-08 9:30 ` [PATCH v2 2/5] bbremote: Convert to python3 Sascha Hauer
2022-09-08 9:30 ` [PATCH v2 3/5] ratp: getenv: Do not crash on non-existing variables Sascha Hauer
2022-09-08 9:30 ` [PATCH v2 4/5] ratp: i2c: Do not return error Sascha Hauer
2022-09-08 9:30 ` Sascha Hauer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220908093005.3035259-6-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox