Skip to content

Commit d92f2c5

Browse files
committed
add error handling around cbapi-{response,defense,protection} scripts
1 parent e8dcc2a commit d92f2c5

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/cbapi/defense/cli.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ def main(args):
8080

8181
opts = parser.parse_args(args)
8282
command = command_map.get(opts.command_name)
83+
if not command:
84+
parser.print_usage()
85+
return
86+
8387
command_method = command.get("method", None)
8488
if command_method:
8589
return command_method(opts)
90+
else:
91+
parser.print_usage()

src/cbapi/protection/cli.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ def main(args):
8787

8888
opts = parser.parse_args(args)
8989
command = command_map.get(opts.command_name)
90+
if not command:
91+
parser.print_usage()
92+
return
93+
9094
command_method = command.get("method", None)
9195
if command_method:
9296
return command_method(opts)
97+
else:
98+
parser.print_usage()

src/cbapi/response/cli.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ def main(args):
101101

102102
opts = parser.parse_args(args)
103103
command = command_map.get(opts.command_name)
104+
if not command:
105+
parser.print_usage()
106+
return
107+
104108
command_method = command.get("method", None)
105109
if command_method:
106110
return command_method(opts)
111+
else:
112+
parser.print_usage()

0 commit comments

Comments
 (0)