diff options
| author | Dennis Fink | 2019-11-18 15:44:38 +0100 |
|---|---|---|
| committer | Dennis Fink | 2019-11-18 15:44:38 +0100 |
| commit | afb6c53a54c1466021a0b7fd09334217f30e94a6 (patch) | |
| tree | 4f28cef11d8a4983dc116985068c8183f10761c3 | |
| parent | bfc52551b5695c0b3f8779f40a0023c8852ab4ce (diff) | |
| parent | f3d89e13a7d101d72ce3369fcb98188458175d4d (diff) | |
| download | patternutils-afb6c53a54c1466021a0b7fd09334217f30e94a6.tar.gz patternutils-afb6c53a54c1466021a0b7fd09334217f30e94a6.zip | |
Merge
Diffstat (limited to '')
| -rw-r--r-- | patternutils/commands/patterncfg.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/patternutils/commands/patterncfg.py b/patternutils/commands/patterncfg.py index 3806b51..96e9ac7 100644 --- a/patternutils/commands/patterncfg.py +++ b/patternutils/commands/patterncfg.py @@ -117,3 +117,24 @@ def view(name: str, command: str, color: bool) -> None: lexer = Python3Lexer text = highlight(text, lexer(), TerminalFormatter()) click.echo(text[:-1]) + + +@patterncfg.command(name='edit', help='edit a template file') +@click.option('-c', '--command', default=None, type=click.Choice(CURRENT_SUPPORTED_PROGRAMS), + help='select the command from which to edit the file') +@click.argument('name') +def edit(name: str, command: str) -> None: + + files = config.find_templates(name, command) + 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: + filename = files[0] + + click.edit(filename=filename) |
