summaryrefslogtreecommitdiff
path: root/patternutils/commands/tmv.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--patternutils/commands/tmv.py85
1 files changed, 45 insertions, 40 deletions
diff --git a/patternutils/commands/tmv.py b/patternutils/commands/tmv.py
index 58a75e5..ecc680b 100644
--- a/patternutils/commands/tmv.py
+++ b/patternutils/commands/tmv.py
@@ -4,6 +4,7 @@ from collections.abc import Iterable
from typing import Any, TextIO
import click
+from click_option_group import optgroup
from .. import config, template, utils
from ..types import TemplateExtensions
@@ -19,86 +20,90 @@ def move_file(old_filename: str, new_filename: str) -> None:
@click.command(context_settings={"help_option_names": ("-h", "--help", "-?")})
-@click.option(
+@optgroup.group("General options")
+@optgroup.option(
"-i",
"--interactive",
is_flag=True,
default=False,
help="Prompt before renaming files.",
)
-@click.option(
+@optgroup.option(
"-e",
"--editor",
is_flag=True,
default=False,
help="Open an editor before renaming files to allow manual changes.",
)
-@click.option(
- "-f",
- "--force",
+@optgroup.option(
+ "-n",
+ "--dry-run",
is_flag=True,
default=False,
- help="Force rename, even if a file exists.",
+ help="Perform a trial run without making changes.",
)
-@click.option(
- "-t",
- "--template-engine",
- default="python",
- type=click.Choice(["python", "jinja2"]),
- help="Select the template engine to use.",
+@optgroup.option(
+ "-v",
+ "--verbose",
+ is_flag=True,
+ default=False,
+ help="Explain what is being done.",
)
-@click.option(
- "-k",
- "--key",
- default="_abspath",
- help="Select the key to use as the source file.",
+@optgroup.group("Input options")
+@optgroup.option(
+ "--read-from",
+ default="-",
+ type=click.File("r"),
+ help="Input file (default: stdin)",
)
-@click.option(
+@optgroup.option(
"-s",
"--stream",
is_flag=True,
default=False,
help="Read input as stream of JSON objects.",
)
-@click.option(
+@optgroup.group("Template options")
+@optgroup.option(
+ "-t",
+ "--template-engine",
+ default="python",
+ type=click.Choice(["python", "jinja2"]),
+ help="Select the template engine to use.",
+)
+@optgroup.option(
"-p",
"--use-predefined-template",
is_flag=True,
default=False,
help="Use a predefined template.",
)
-@click.option(
- "--read-from",
- default="-",
- type=click.File("r"),
- help="Input file (default: stdin)",
+@optgroup.group("Renaming options")
+@optgroup.option(
+ "-k",
+ "--key",
+ default="_abspath",
+ help="Select the key to use as the source file.",
+)
+@optgroup.option(
+ "-f",
+ "--force",
+ is_flag=True,
+ default=False,
+ help="Force rename, even if a file exists.",
)
-@click.option(
+@optgroup.option(
"--abort-on-path-exist",
is_flag=True,
default=False,
help="Exit if a renamed path already exists.",
)
-@click.option(
+@optgroup.option(
"--abort-on-key-not-found",
is_flag=True,
default=False,
help="Exit if the specified key (specified by the --key option) is not found in the input JSON.",
)
-@click.option(
- "-n",
- "--dry-run",
- is_flag=True,
- default=False,
- help="Perform a trial run without making changes.",
-)
-@click.option(
- "-v",
- "--verbose",
- is_flag=True,
- default=False,
- help="Explain what is being done.",
-)
@click.version_option()
@click.argument("output-pattern")
def tmv(