44 lines
1.5 KiB
Python
44 lines
1.5 KiB
Python
from argparse import ArgumentParser
|
|
from pathlib import Path
|
|
|
|
from . import __version__
|
|
from .logger import logger
|
|
from .validation import validate_file_folder
|
|
|
|
|
|
def run() -> None:
|
|
"""
|
|
Command-line interface for ${REPO_NAME_SNAKE}.
|
|
|
|
This function defines and handles command-line arguments for the program.
|
|
The available options are:
|
|
|
|
--version: Show the version of the program and exit.
|
|
--verbose: Enable verbose logging. This will produce detailed output messages.
|
|
--output/-o: Specify the output file. This must be a valid file path.
|
|
paths: Specify any number of existing files or directories to be processed.
|
|
These paths must point to existing files or directories.
|
|
|
|
Upon parsing the command-line arguments, the function configures the logger
|
|
and invokes the `main` function with the parsed arguments.
|
|
|
|
Returns:
|
|
None
|
|
"""
|
|
# your code here
|
|
parser = ArgumentParser(description="${REPO_DESCRIPTION}")
|
|
parser.add_argument("--version", action="version", version=__version__)
|
|
parser.add_argument("--verbose", action="store_true", help="Enable verbose logging")
|
|
parser.add_argument("--output", "-o", type=Path, help="Specify output file")
|
|
parser.add_argument(
|
|
"paths",
|
|
nargs="+",
|
|
type=validate_file_folder,
|
|
help="Specify any number of existing files or directories to be processed.",
|
|
)
|
|
args = parser.parse_args()
|
|
|
|
if args.verbose:
|
|
logger.debug("Verbose logging enabled")
|
|
|
|
run(args)
|