|
1 |
| -from lib.cmd2 import Cmd, with_category |
| 1 | +import argparse |
| 2 | +from lib.cmd2 import Cmd, with_category, with_argparser |
2 | 3 | from art import text2art, art
|
3 | 4 | from utils import module
|
4 | 5 | from pathlib import Path
|
@@ -71,17 +72,21 @@ def complete_set(self, text, line, begidx, endidx):
|
71 | 72 | completion_items += [option.name for option in self.module_instance.options.get_options()]
|
72 | 73 | return self.basic_complete(text, line, begidx, endidx, completion_items)
|
73 | 74 |
|
| 75 | + set_parser = argparse.ArgumentParser() |
| 76 | + set_parser.add_argument("name", help="The name of the field you want to set") |
| 77 | + set_parser.add_argument("value", help="The value of the field you want to set") |
| 78 | + |
| 79 | + @with_argparser(set_parser) |
74 | 80 | @with_category(CMD_MODULE)
|
75 | 81 | def do_set(self, args):
|
76 |
| - [arg, value] = args.split(" ") |
77 |
| - if arg == 'debug': |
78 |
| - self.debug = value |
| 82 | + if args.value == 'debug': |
| 83 | + self.debug = args.value |
79 | 84 | return None
|
80 | 85 |
|
81 | 86 | if not self.module_instance:
|
82 | 87 | raise ModuleNotUseException()
|
83 | 88 |
|
84 |
| - self.module_instance.options.set_option(arg, value) |
| 89 | + self.module_instance.options.set_option(args.name, args.value) |
85 | 90 |
|
86 | 91 | def complete_use(self, text, line, begidx, endidx):
|
87 | 92 | if len(line.split(" ")) > 2:
|
|
0 commit comments