2025-11-16 11:39:27 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
|
|
from argparse import Namespace, ArgumentParser
|
|
|
|
|
|
|
|
|
|
from ..Cmd import Cmd
|
|
|
|
|
|
|
|
|
|
class CmdGetval(Cmd): # export
|
|
|
|
|
|
|
|
|
|
def __init__(self) -> None:
|
|
|
|
|
super().__init__('getval', help='Get value from project config')
|
|
|
|
|
|
|
|
|
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
|
|
|
|
super().add_arguments(parser)
|
2026-01-21 14:08:44 +01:00
|
|
|
parser.add_argument('--project', default = None, help = 'Project name, default is name of project\'s topdir')
|
2025-11-16 11:39:27 +01:00
|
|
|
parser.add_argument('section', default = '', help = 'Config section')
|
|
|
|
|
parser.add_argument('key', default = '', help = 'Config key')
|
|
|
|
|
|
|
|
|
|
def _run(self, args: Namespace) -> None:
|
2026-01-21 14:08:44 +01:00
|
|
|
project = args.project
|
|
|
|
|
if project is None:
|
|
|
|
|
args.project = self.app.top_name
|
2025-11-16 11:39:27 +01:00
|
|
|
print(self.app.get_value(args.project, args.section, args.key))
|