mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-25 09:35:54 +02:00
cmds.CmdGetval.add_arguments(): Don't use app.top_name
CmdGetval.add_arguments() uses self.app.top_name, which may or may not be initialized at the time this runs. Not using it makes CmdGetval's ctor safe to run in the context of App.__init__(). Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
f869b5aaca
commit
eb2dd919a1
1 changed files with 4 additions and 1 deletions
|
|
@ -11,9 +11,12 @@ class CmdGetval(Cmd): # export
|
||||||
|
|
||||||
def add_arguments(self, parser: ArgumentParser) -> None:
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
||||||
super().add_arguments(parser)
|
super().add_arguments(parser)
|
||||||
parser.add_argument('--project', default = self.app.top_name, help = 'Project name')
|
parser.add_argument('--project', default = None, help = 'Project name, default is name of project\'s topdir')
|
||||||
parser.add_argument('section', default = '', help = 'Config section')
|
parser.add_argument('section', default = '', help = 'Config section')
|
||||||
parser.add_argument('key', default = '', help = 'Config key')
|
parser.add_argument('key', default = '', help = 'Config key')
|
||||||
|
|
||||||
def _run(self, args: Namespace) -> None:
|
def _run(self, args: Namespace) -> None:
|
||||||
|
project = args.project
|
||||||
|
if project is None:
|
||||||
|
args.project = self.app.top_name
|
||||||
print(self.app.get_value(args.project, args.section, args.key))
|
print(self.app.get_value(args.project, args.section, args.key))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue