From 143dd6487c355b7172ce33f565a2427c22f628c8 Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Wed, 28 Aug 2019 22:42:51 +0200 Subject: Use a global tuple for the supported commands in patterncfg --- patternutils/commands/patterncfg.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/patternutils/commands/patterncfg.py b/patternutils/commands/patterncfg.py index aace2ba..231940c 100644 --- a/patternutils/commands/patterncfg.py +++ b/patternutils/commands/patterncfg.py @@ -8,6 +8,9 @@ import click from .. import config +CURRENT_SUPPORTED_PROGRAMS = ('pmatch', 'tmv', 'targs') + + @click.group(context_settings={'help_option_names': ('-h', '--help', '-?')}) def patterncfg() -> None: pass @@ -15,7 +18,7 @@ def patterncfg() -> None: @patterncfg.command(name='init', help='initialize config folders') def init() -> None: - for dir in ['pmatch', 'tmv', 'targs']: + for dir in CURRENT_SUPPORTED_PROGRAMS: os.makedirs(os.path.join(config.CONFIG_PATH, dir), exist_ok=True) @@ -48,7 +51,7 @@ def add(file_type: str, command: Optional[str], name: str) -> None: @patterncfg.command(name='remove', help='remove template file') -@click.option('-c', '--command', default=None, type=click.Choice(['pmatch', 'tmv', 'targs']), +@click.option('-c', '--command', default=None, type=click.Choice(CURRENT_SUPPORTED_PROGRAMS), help='select the command from which to view the file') @click.argument('name') def remove(command: Optional[str], name: str) -> None: @@ -68,7 +71,7 @@ def remove(command: Optional[str], name: str) -> None: @patterncfg.command(name='view', help='view template file') -@click.option('-c', '--command', default=None, type=click.Choice(['pmatch', 'tmv', 'targs']), +@click.option('-c', '--command', default=None, type=click.Choice(CURRENT_SUPPORTED_PROGRAMS), help='select the command from which to view the file') @click.argument('name') def view(name: str, command: str) -> None: -- cgit v1.3.1