File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99- ` pybricksdev.ble.lwp3.bytecodes ` module.
1010- ` pybricksdev.ble.lwp3.messages ` module.
1111- ` pybricksdev lwp3 repl ` command line tool.
12+ ## Fixed
13+ - Crash when running ` pybricksdev dfu ` without args on command line.
1214
1315## [ 1.0.0-alpha.8] - 2021-05-18
1416## Added
Original file line number Diff line number Diff line change @@ -242,19 +242,24 @@ async def run(self, args: argparse.Namespace):
242242
243243class DFU (Tool ):
244244 def add_parser (self , subparsers : argparse ._SubParsersAction ):
245- parser = subparsers .add_parser (
245+ self . parser = subparsers .add_parser (
246246 "dfu" ,
247247 help = "use DFU to backup or restore firmware" ,
248248 )
249- parser .tool = self
250- self .subparsers = parser .add_subparsers (
249+ self . parser .tool = self
250+ self .subparsers = self . parser .add_subparsers (
251251 metavar = "<action>" , dest = "action" , help = "the action to perform"
252252 )
253253
254254 for tool in DFUBackup (), DFURestore ():
255255 tool .add_parser (self .subparsers )
256256
257257 def run (self , args : argparse .Namespace ):
258+ if args .action not in self .subparsers .choices :
259+ self .parser .error (
260+ f'Missing name of action: { "|" .join (self .subparsers .choices .keys ())} '
261+ )
262+
258263 return self .subparsers .choices [args .action ].tool .run (args )
259264
260265
You can’t perform that action at this time.
0 commit comments