diff options
Diffstat (limited to '')
| -rw-r--r-- | patternutils/commands/patterncfg.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/patternutils/commands/patterncfg.py b/patternutils/commands/patterncfg.py index 434387d..aace2ba 100644 --- a/patternutils/commands/patterncfg.py +++ b/patternutils/commands/patterncfg.py @@ -54,11 +54,17 @@ def add(file_type: str, command: Optional[str], name: str) -> None: def remove(command: Optional[str], name: str) -> None: files = config.find_templates(name, command) - try: - os.remove(files[0]) - except IndexError: - click.secho('Cannot remove {}. It doesn\'t exist!'.format(name), fg='red', err=True) + + if not files: + click.secho('No files found!', fg='red', err=True) + raise SystemExit + elif len(files) != 1: + click.secho('Multiple files found!', fg='red', err=True) + for f in files: + click.secho(f, fg='red', err=True) raise SystemExit + else: + os.remove(files[0]) @patterncfg.command(name='view', help='view template file') |
