From f08b850f297422925b8e0a16d67accee6843b9e1 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Wed, 15 Jun 2022 04:47:41 -0400 Subject: T2719: handle the case when script subcommand is not given --- python/vyos/opmode.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'python') diff --git a/python/vyos/opmode.py b/python/vyos/opmode.py index c0812c7fd..692e5fc98 100644 --- a/python/vyos/opmode.py +++ b/python/vyos/opmode.py @@ -13,6 +13,7 @@ # You should have received a copy of the GNU Lesser General Public # License along with this library. If not, see . +import sys import typing @@ -97,6 +98,11 @@ def run(module): # so that we can modify it and pack for passing to functions args = vars(parser.parse_args()) + if not args["subcommand"]: + print("Subcommand required!") + parser.print_usage() + sys.exit(1) + func = functions[args["subcommand"]] # Remove the subcommand from the arguments, -- cgit v1.2.3