diff options
Diffstat (limited to '')
| -rw-r--r-- | patternutils/commands/tmv.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/patternutils/commands/tmv.py b/patternutils/commands/tmv.py index b8d5d73..5c2da98 100644 --- a/patternutils/commands/tmv.py +++ b/patternutils/commands/tmv.py @@ -6,6 +6,7 @@ import click from .. import template from .. import config +from .. import utils def move_file(old_filename: str, new_filename: str) -> None: @@ -20,13 +21,15 @@ def move_file(old_filename: str, new_filename: str) -> None: @click.command(context_settings={'help_option_names': ('-h', '--help', '-?')}) @click.option('-i', '--interactive', is_flag=True, default=False, help='prompt before renaming files') +@click.option('-e', '--editor', is_flag=True, default=False, + help='Open an editor before renaming files') @click.option('-f', '--force', is_flag=True, default=False, help='force rename') @click.option('-t', '--template-engine', default='python', type=click.Choice(['python', 'jinja2']), help='select the template engine to use') @click.option('-k', '--key', default='_abspath', help='select the key to use as the source file') -@click.option('-s', '--stream', if_flag=True, default=False, +@click.option('-s', '--stream', is_flag=True, default=False, help='Input is a stream of JSON objects') @click.option('-p', '--use-predefined-template', is_flag=True, default=False, help='use predefined template') @@ -42,6 +45,7 @@ def move_file(old_filename: str, new_filename: str) -> None: def tmv( output_pattern: str, interactive: bool, + editor: bool, force: bool, template_engine: str, abort_on_path_exist: bool, @@ -91,6 +95,13 @@ def tmv( new_filenames = dict((entry[key], render(**entry)) for entry in data) + if editor: + try: + new_filenames = utils.edit(new_filenames) + except RuntimeError: + click.secho('You edit is not parseable!', fg='red', err=True) + raise SystemExit + has_existing = False non_existing = {} for old, new in new_filenames.items(): |
