RRZE-HPC / stempel

Stencil TEMPlate Engineering Library
GNU Affero General Public License v3.0
6 stars 2 forks source link

Fails on no arguments #21

Closed cod3monk closed 7 years ago

cod3monk commented 7 years ago
$ python stempel.py
Traceback (most recent call last):
  File "stempel.py", line 457, in <module>
    main()
  File "stempel.py", line 454, in main
    args.func(args, parser)
AttributeError: 'Namespace' object has no attribute 'func'
$

should either do something useful or return the help text.

sguera commented 7 years ago

Actually I get a different output when running that line:

python stempel.py usage: stempel.py [-h] {gen,bench} ... stempel.py: error: too few arguments

cod3monk commented 7 years ago

You must have a different code, because only the subparsers parser_gen and parser_bench provide a func argument. If neither is invoked the argument won't exist.

At least that is my interpretation of the create_parser() and main() functions.

cod3monk commented 7 years ago

You can add subparsers.required = True to require the user to select a subparser. If not, parsing will throw and handle an exception and never get to the "business logic" (args.func(args, parser)).

sguera commented 7 years ago

fixed in https://github.com/RRZE-HPC/stempel/commit/545215dcc6db605493375031d606ef0330372a95