diff options
| author | Dennis Fink | 2019-08-28 22:43:09 +0200 |
|---|---|---|
| committer | Dennis Fink | 2019-08-28 22:43:09 +0200 |
| commit | 702bc013ce0b4c782d6385b9c8042bd26a387425 (patch) | |
| tree | 040f9765b34ae0a6a27b9d58f544c648a6dd694e | |
| parent | 143dd6487c355b7172ce33f565a2427c22f628c8 (diff) | |
| download | patternutils-702bc013ce0b4c782d6385b9c8042bd26a387425.tar.gz patternutils-702bc013ce0b4c782d6385b9c8042bd26a387425.zip | |
Fail gracefully when patterncfg init was not run
Diffstat (limited to '')
| -rw-r--r-- | patternutils/commands/patterncfg.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/patternutils/commands/patterncfg.py b/patternutils/commands/patterncfg.py index 231940c..e2432d6 100644 --- a/patternutils/commands/patterncfg.py +++ b/patternutils/commands/patterncfg.py @@ -24,10 +24,14 @@ def init() -> None: @patterncfg.command(name='list', help='list all patternutils template files') def list() -> None: - for d in os.listdir(config.CONFIG_PATH): - click.secho(d, fg='blue') - for f in os.listdir(os.path.join(config.CONFIG_PATH, d)): - click.echo('└── {}'.format(f)) + try: + for d in os.listdir(config.CONFIG_PATH): + click.secho(d, fg='blue') + for f in os.listdir(os.path.join(config.CONFIG_PATH, d)): + click.echo('└── {}'.format(f)) + except FileNotFoundError as e: + click.secho('{} not found! Please run patterncfg init first.'.format(e.filename), fg='red', err=True) + raise SystemExit @patterncfg.command(name='add', help='add new template file') |
