diff --git a/mdsanima_cli/__init__.py b/mdsanima_cli/__init__.py index cb4df67..4d44d4a 100644 --- a/mdsanima_cli/__init__.py +++ b/mdsanima_cli/__init__.py @@ -5,24 +5,13 @@ from __future__ import annotations -from mdsanima_cli.commands.check import cli_check -from mdsanima_cli.commands.gifmaker import cli_gifmaker -from mdsanima_cli.commands.grid import cli_grid -from mdsanima_cli.commands.jpg import cli_jpg -from mdsanima_cli.commands.logo import cli_logo -from mdsanima_cli.commands.number import cli_number -from mdsanima_cli.commands.pixelart import cli_pixelart -from mdsanima_cli.commands.png import cli_png -from mdsanima_cli.commands.resize import cli_resize -from mdsanima_cli.commands.thumbnail import cli_thumbnail -from mdsanima_cli.commands.uuids import cli_uuid -from mdsanima_cli.commands.watermark import cli_watermark -from mdsanima_cli.commands.webp import cli_webp +from mdsanima_cli.core import cmd +from mdsanima_cli.core.cli import Command from mdsanima_cli.core.cli import create_parser -from mdsanima_cli.utils.ascii import ascii_title +from mdsanima_cli.core.utils.ascii import ascii_title -def main_cli(): +def cli(): """The main command-line functionality responsible for sub-functions and allocation separation.""" # Creating argument parser. @@ -35,31 +24,31 @@ def main_cli(): try: if args.COMMAND is None: parser.print_help() - if args.COMMAND == "check": - cli_check() - if args.COMMAND == "logo": - cli_logo() - if args.COMMAND == "watermark": - cli_watermark() - if args.COMMAND == "number": - cli_number() - if args.COMMAND == "uuid": - cli_uuid() - if args.COMMAND == "resize": - cli_resize() - if args.COMMAND == "jpg": - cli_jpg() - if args.COMMAND == "png": - cli_png() - if args.COMMAND == "webp": - cli_webp() - if args.COMMAND == "grid": - cli_grid() - if args.COMMAND == "pixelart": - cli_pixelart() - if args.COMMAND == "gifmaker": - cli_gifmaker() - if args.COMMAND == "thumbnail": - cli_thumbnail() + if args.COMMAND == f"{Command.CHECK.cmd}": + cmd.check() + if args.COMMAND == f"{Command.LOGO.cmd}": + cmd.logo() + if args.COMMAND == f"{Command.WATERMARK.cmd}": + cmd.watermark() + if args.COMMAND == f"{Command.NUMBER.cmd}": + cmd.number() + if args.COMMAND == f"{Command.UUID.cmd}": + cmd.uuid() + if args.COMMAND == f"{Command.RESIZE.cmd}": + cmd.resize() + if args.COMMAND == f"{Command.JPG.cmd}": + cmd.jpg() + if args.COMMAND == f"{Command.PNG.cmd}": + cmd.png() + if args.COMMAND == f"{Command.WEBP.cmd}": + cmd.webp() + if args.COMMAND == f"{Command.GRID.cmd}": + cmd.grid() + if args.COMMAND == f"{Command.PIXELART.cmd}": + cmd.pixelart() + if args.COMMAND == f"{Command.GIFMAKER.cmd}": + cmd.gifmaker() + if args.COMMAND == f"{Command.THUMBNAIL.cmd}": + cmd.thumbnail() except AttributeError: parser.print_help() diff --git a/mdsanima_cli/__main__.py b/mdsanima_cli/__main__.py index 1ec840b..33e0410 100644 --- a/mdsanima_cli/__main__.py +++ b/mdsanima_cli/__main__.py @@ -5,8 +5,8 @@ from __future__ import annotations -from mdsanima_cli import main_cli +from mdsanima_cli import cli if __name__ == "__main__": - raise SystemExit(main_cli()) + raise SystemExit(cli()) diff --git a/mdsanima_cli/commands/__init__.py b/mdsanima_cli/commands/__init__.py deleted file mode 100644 index ab8335d..0000000 --- a/mdsanima_cli/commands/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# Copyright (c) 2023 MDSANIMA diff --git a/mdsanima_cli/core/cli/__init__.py b/mdsanima_cli/core/cli/__init__.py index b9bad3e..567eca8 100644 --- a/mdsanima_cli/core/cli/__init__.py +++ b/mdsanima_cli/core/cli/__init__.py @@ -5,8 +5,8 @@ from mdsanima_cli.core.cli.command import Command from mdsanima_cli.core.cli.config import Config -from mdsanima_cli.core.cli.formatter import PrettyHelpFormatter +from mdsanima_cli.core.cli.formatter import PrettyHelp from mdsanima_cli.core.cli.parser import create_parser -__all__ = ["Command", "Config", "PrettyHelpFormatter", "create_parser"] +__all__ = ["Command", "Config", "PrettyHelp", "create_parser"] diff --git a/mdsanima_cli/core/cli/command.py b/mdsanima_cli/core/cli/command.py index ebe08c5..a7bdf02 100644 --- a/mdsanima_cli/core/cli/command.py +++ b/mdsanima_cli/core/cli/command.py @@ -21,21 +21,24 @@ class _SubCommandAction(Enum): def add_parser(self, subparsers): """Create and add a subparser for the command.""" _desc = self.value.description - return subparsers.add_parser(name=self.value.cli, help=self.value.help, description=_desc, add_help=False) + return subparsers.add_parser(name=self.value.cmd, help=self.value.help, description=_desc, add_help=False) @property - def show_cli(self) -> str: - """Returning the string value of the `CLI` subcommand name as a property.""" - return self.value.cli + def show(self) -> str: + """Returning the string value of the `cmd` subcommand name as a property.""" + return self.value.cmd @dataclass class SubCommandDataMixin: - """Mixin for subcommand data types used in subparsers, displayed in command-line help.""" + """Mixin for subcommand data types used in subparsers, displayed in the command-line interface help.""" - cli: str + cmd: str + """The name of the `CLI` command used for dataset processing.""" help: str + """The short help text about the `CLI` command that is displayed in the command-line interface help.""" description: str + """The long help description text that provides detailed information about the `CLI` command.""" class Command(SubCommandDataMixin, _SubCommandAction, AutoNameLower): diff --git a/mdsanima_cli/core/cli/config.py b/mdsanima_cli/core/cli/config.py index b02c514..c692624 100644 --- a/mdsanima_cli/core/cli/config.py +++ b/mdsanima_cli/core/cli/config.py @@ -9,7 +9,7 @@ from enum import unique from mdsanima_cli._version import __version__ -from mdsanima_cli.core.enums.target import Target +from mdsanima_cli.core.enums import Target @unique @@ -29,15 +29,15 @@ class Config(Enum): """The description of what the program does.""" CLI_EPILOG = f"Copyright (c) 2023 {Target.MDSANIMA}" - """The text at the bottom of CLI program.""" + """The text at the bottom of `CLI` program.""" CLI_VERSION = f"{CLI_NAME}-cli v{__version__}" - """The CLI name and the version of the program.""" + """The `CLI` name and the version of the program.""" - OPT_INFO_VERSION = "Show version" + OPT_INFO = "Show version" """The help information thats is show on version action.""" - OPT_INFO_HELP = "Show help" + OPT_HELP = "Show help" """The help information thats is show on help action.""" TITLE_CMD = "Commands" diff --git a/mdsanima_cli/core/cli/formatter.py b/mdsanima_cli/core/cli/formatter.py index 5969200..4ad347b 100644 --- a/mdsanima_cli/core/cli/formatter.py +++ b/mdsanima_cli/core/cli/formatter.py @@ -8,7 +8,7 @@ import argparse -class PrettyHelpFormatter(argparse.HelpFormatter): +class PrettyHelp(argparse.HelpFormatter): """Custom help formatter for adjusting help strings that are generated on argparse.""" def _format_usage(self, usage, actions, groups, prefix): diff --git a/mdsanima_cli/core/cli/parser.py b/mdsanima_cli/core/cli/parser.py index 91ca2c8..bae72a1 100644 --- a/mdsanima_cli/core/cli/parser.py +++ b/mdsanima_cli/core/cli/parser.py @@ -9,22 +9,16 @@ from mdsanima_cli.core.cli import Command from mdsanima_cli.core.cli import Config -from mdsanima_cli.core.cli import PrettyHelpFormatter +from mdsanima_cli.core.cli import PrettyHelp from mdsanima_cli.core.enums import Target def create_parser() -> argparse.ArgumentParser: """Create an argument parser for all available commands.""" - # The initial variables. - _version = f"{Config.CLI_VERSION}" - _info_version = f"{Config.OPT_INFO_VERSION}" - _info_help = f"{Config.OPT_INFO_HELP}" - _metavar = f"{Config.TITLE_CMD}" - # Create the top-level parser. - parser = argparse.ArgumentParser(formatter_class=PrettyHelpFormatter, add_help=False, allow_abbrev=False) - subparsers = parser.add_subparsers(dest=f"{Target.COMMAND}", metavar=f"\r{_metavar}:") + parser = argparse.ArgumentParser(formatter_class=PrettyHelp, add_help=False, allow_abbrev=False) + subparsers = parser.add_subparsers(dest=f"{Target.COMMAND}", metavar=f"\r{Config.TITLE_CMD}:") # The new titles for the parser. parser._subparsers.title = None @@ -36,15 +30,15 @@ def create_parser() -> argparse.ArgumentParser: parser.description = f"{Config.CLI_DESCRIPTION}" parser.epilog = f"{Config.CLI_RUN}" - # Adding the optionals artument with the new config. - parser.add_argument("-v", "--version", action="version", help=_info_version, version=_version) - parser.add_argument("-h", "--help", action="help", help=_info_help) - # Create the parsers for the commands. for cmd in list(Command): parser_cmd = cmd.add_parser(subparsers) - parser_cmd.formatter_class = PrettyHelpFormatter - parser_cmd.set_defaults(command=cmd.show_cli) + parser_cmd.formatter_class = PrettyHelp + parser_cmd.set_defaults(command=cmd.show) parser_cmd.add_argument("--help", action="help", help=argparse.SUPPRESS) + # Adding the optionals artument with the new config. + parser.add_argument("-v", "--version", action="version", help=f"{Config.OPT_INFO}", version=f"{Config.CLI_VERSION}") + parser.add_argument("-h", "--help", action="help", help=f"{Config.OPT_HELP}") + return parser diff --git a/mdsanima_cli/core/cmd/__init__.py b/mdsanima_cli/core/cmd/__init__.py index e412520..1cc810e 100644 --- a/mdsanima_cli/core/cmd/__init__.py +++ b/mdsanima_cli/core/cmd/__init__.py @@ -1,3 +1,35 @@ # Copyright (c) 2023 MDSANIMA """This module holds the all commands functionality on the `CLI` interface.""" + + +from mdsanima_cli.core.cmd.check import check +from mdsanima_cli.core.cmd.gifmaker import gifmaker +from mdsanima_cli.core.cmd.grid import grid +from mdsanima_cli.core.cmd.jpg import jpg +from mdsanima_cli.core.cmd.logo import logo +from mdsanima_cli.core.cmd.number import number +from mdsanima_cli.core.cmd.pixelart import pixelart +from mdsanima_cli.core.cmd.png import png +from mdsanima_cli.core.cmd.resize import resize +from mdsanima_cli.core.cmd.thumbnail import thumbnail +from mdsanima_cli.core.cmd.uuid import uuid +from mdsanima_cli.core.cmd.watermark import watermark +from mdsanima_cli.core.cmd.webp import webp + + +__all__ = [ + "check", + "gifmaker", + "grid", + "jpg", + "logo", + "number", + "pixelart", + "png", + "resize", + "thumbnail", + "uuid", + "watermark", + "webp", +] diff --git a/mdsanima_cli/commands/check.py b/mdsanima_cli/core/cmd/check.py similarity index 60% rename from mdsanima_cli/commands/check.py rename to mdsanima_cli/core/cmd/check.py index 9c4e082..76fe689 100644 --- a/mdsanima_cli/commands/check.py +++ b/mdsanima_cli/core/cmd/check.py @@ -1,25 +1,23 @@ # Copyright (c) 2023 MDSANIMA - -"""Checking and displaying info about all images in current directory.""" +"""Checking and displaying statistic information about images.""" from __future__ import annotations -from mdsanima_cli.parser import CHECK_COMD -from mdsanima_cli.parser import CHECK_HELP -from mdsanima_cli.utils.print import print_cli_data -from mdsanima_cli.utils.print import print_cli_info -from mdsanima_cli.utils.stats import get_directory_statistic +from mdsanima_cli.core.cli import Command +from mdsanima_cli.core.utils.print import print_cli_data +from mdsanima_cli.core.utils.print import print_cli_info +from mdsanima_cli.core.utils.stats import get_directory_statistic def directory_statistic(cli_command: str, cli_help: str) -> str: - """Printing info about all images inside the current directory.""" + """Printing info about all image files inside the current directory.""" # Get directory stats info and color print. info = get_directory_statistic() - # Print color info stats. + # Printing color information statistics for image files. print_cli_info("mdsanima cli", cli_command, 40, 34, 12) print_cli_info("info cli", cli_help, 40, 34, 5) print_cli_data("path", info["path"], 34, 26, 38) @@ -34,6 +32,6 @@ def directory_statistic(cli_command: str, cli_help: str) -> str: print_cli_data("other", info["other"], 34, 24, 52) -def cli_check() -> None: - """Main function for `check` command.""" - directory_statistic(CHECK_COMD, CHECK_HELP) +def check() -> None: + """The main functionality for the `check` command.""" + directory_statistic(f"{Command.CHECK.cmd}", f"{Command.CHECK.help}") diff --git a/mdsanima_cli/commands/gifmaker.py b/mdsanima_cli/core/cmd/gifmaker.py similarity index 78% rename from mdsanima_cli/commands/gifmaker.py rename to mdsanima_cli/core/cmd/gifmaker.py index 2d9db2c..23fe8ca 100644 --- a/mdsanima_cli/commands/gifmaker.py +++ b/mdsanima_cli/core/cmd/gifmaker.py @@ -1,7 +1,6 @@ # Copyright (c) 2023 MDSANIMA - -"""Generating pixel art animation GIF. It operates within a specified folder and can process all images at once.""" +"""Generate GIF pixel art animation. It operates within a specified folder and can process all images at once.""" from __future__ import annotations @@ -11,17 +10,16 @@ from PIL import Image -from mdsanima_cli.commands.check import directory_statistic -from mdsanima_cli.commands.pixelart import generate_pixelart -from mdsanima_cli.commands.resize import generate_resize -from mdsanima_cli.parser import GIFMAKER_COMD -from mdsanima_cli.parser import GIFMAKER_HELP -from mdsanima_cli.utils.ascii import ascii_title -from mdsanima_cli.utils.exif import get_exif_bytes -from mdsanima_cli.utils.print import print_cli_comp -from mdsanima_cli.utils.print import print_cli_done -from mdsanima_cli.utils.print import print_cli_proc -from mdsanima_cli.utils.timer import timer +from mdsanima_cli.core.cli import Command +from mdsanima_cli.core.cmd.check import directory_statistic +from mdsanima_cli.core.cmd.pixelart import generate_pixelart +from mdsanima_cli.core.cmd.resize import generate_resize +from mdsanima_cli.core.utils.ascii import ascii_title +from mdsanima_cli.core.utils.exif import get_exif_bytes +from mdsanima_cli.core.utils.print import print_cli_comp +from mdsanima_cli.core.utils.print import print_cli_done +from mdsanima_cli.core.utils.print import print_cli_proc +from mdsanima_cli.core.utils.timer import timer TMP_PATH = os.path.expanduser("~/.mdsanima-cli/tmp/gifmaker") @@ -56,7 +54,7 @@ def generate_tmp_images(image_path: str) -> None: @timer def generate_gifmaker(image_path: str, gif_name: str, gif_duration: int, count: int) -> None: - """Generate one pixel art animation GIF from temporary images, then save the result with a new name and exif data. + """Generate one GIF pixel art animation from temporary images, then save the result with a new name and exif data. Original image is resized to 512px width. Printing color info. """ @@ -91,17 +89,10 @@ def generate_gifmaker(image_path: str, gif_name: str, gif_duration: int, count: durations = [gif_duration] * len(images) # Add exif data. - exif_bytes = get_exif_bytes(GIFMAKER_HELP) + exif_bytes = get_exif_bytes(f"{Command.GIFMAKER.help}") # Save the result. - image.save( - gif_name, - save_all=True, - append_images=images[1:], - duration=durations, - loop=0, - exif=exif_bytes, - ) + image.save(gif_name, save_all=True, append_images=images[1:], duration=durations, loop=0, exif=exif_bytes) @timer @@ -141,9 +132,9 @@ def compute_gifmaker() -> None: count += 1 -def cli_gifmaker() -> None: - """Main function for `gifmaker` command.""" - directory_statistic(GIFMAKER_COMD, GIFMAKER_HELP) +def gifmaker() -> None: + """The main functionality for the `gifmaker` command.""" + directory_statistic(f"{Command.GIFMAKER.cmd}", f"{Command.GIFMAKER.help}") ascii_title("processing") time_taken = compute_gifmaker() ascii_title("completed") diff --git a/mdsanima_cli/commands/grid.py b/mdsanima_cli/core/cmd/grid.py similarity index 81% rename from mdsanima_cli/commands/grid.py rename to mdsanima_cli/core/cmd/grid.py index c998d04..8b6c2e2 100644 --- a/mdsanima_cli/commands/grid.py +++ b/mdsanima_cli/core/cmd/grid.py @@ -1,9 +1,6 @@ # Copyright (c) 2023 MDSANIMA - -"""Generating a grid from all images in the current directory. It operates within a specified folder and can process all -images at once. -""" +"""Generate 2x2 grid from four images. It operates within a specified folder and can process all images at once.""" from __future__ import annotations @@ -12,15 +9,14 @@ from PIL import Image -from mdsanima_cli.commands.check import directory_statistic -from mdsanima_cli.parser import GRID_COMD -from mdsanima_cli.parser import GRID_HELP -from mdsanima_cli.utils.ascii import ascii_title -from mdsanima_cli.utils.exif import get_exif_bytes -from mdsanima_cli.utils.print import print_cli_comp -from mdsanima_cli.utils.print import print_cli_done -from mdsanima_cli.utils.print import print_cli_proc -from mdsanima_cli.utils.timer import timer +from mdsanima_cli.core.cli import Command +from mdsanima_cli.core.cmd.check import directory_statistic +from mdsanima_cli.core.utils.ascii import ascii_title +from mdsanima_cli.core.utils.exif import get_exif_bytes +from mdsanima_cli.core.utils.print import print_cli_comp +from mdsanima_cli.core.utils.print import print_cli_done +from mdsanima_cli.core.utils.print import print_cli_proc +from mdsanima_cli.core.utils.timer import timer @timer @@ -46,7 +42,7 @@ def generate_grid(image_1_path: str, image_2_path: str, image_3_path: str, image grid_image.paste(image_4, (image_1.size[0], image_1.size[1])) # Add exif data. - exif_bytes = get_exif_bytes(GRID_HELP) + exif_bytes = get_exif_bytes(f"{Command.GRID.help}") # Save the result. grid_image.save(grid_name, exif=exif_bytes) @@ -105,9 +101,9 @@ def compute_grid() -> None: count += 1 -def cli_grid() -> None: - """Main function for `grid` command.""" - directory_statistic(GRID_COMD, GRID_HELP) +def grid() -> None: + """The main functionality for the `grid` command.""" + directory_statistic(f"{Command.GRID.cmd}", f"{Command.GRID.help}") ascii_title("processing") time_taken = compute_grid() ascii_title("completed") diff --git a/mdsanima_cli/commands/jpg.py b/mdsanima_cli/core/cmd/jpg.py similarity index 71% rename from mdsanima_cli/commands/jpg.py rename to mdsanima_cli/core/cmd/jpg.py index fb85d74..c346101 100644 --- a/mdsanima_cli/commands/jpg.py +++ b/mdsanima_cli/core/cmd/jpg.py @@ -1,9 +1,6 @@ # Copyright (c) 2023 MDSANIMA - -"""Converting images to JPG format from all images in the curreny directory. It operates within a specified folder and -can process all images at once. -""" +"""Convert images to JPG format. It operates within a specified folder and can process all images at once.""" from __future__ import annotations @@ -12,14 +9,13 @@ from PIL import Image -from mdsanima_cli.commands.check import directory_statistic -from mdsanima_cli.parser import JPG_COMD -from mdsanima_cli.parser import JPG_HELP -from mdsanima_cli.utils.ascii import ascii_title -from mdsanima_cli.utils.exif import get_exif_bytes -from mdsanima_cli.utils.print import print_cli_done -from mdsanima_cli.utils.print import print_cli_proc -from mdsanima_cli.utils.timer import timer +from mdsanima_cli.core.cli import Command +from mdsanima_cli.core.cmd.check import directory_statistic +from mdsanima_cli.core.utils.ascii import ascii_title +from mdsanima_cli.core.utils.exif import get_exif_bytes +from mdsanima_cli.core.utils.print import print_cli_done +from mdsanima_cli.core.utils.print import print_cli_proc +from mdsanima_cli.core.utils.timer import timer @timer @@ -30,7 +26,7 @@ def convert_to_jpg(image_path: str, new_name: str) -> None: image = Image.open(image_path) # Add exif data. - exif_bytes = get_exif_bytes(JPG_HELP) + exif_bytes = get_exif_bytes(f"{Command.JPG.help}") # Save the result. image.save(new_name, "JPEG", exif=exif_bytes) @@ -69,9 +65,9 @@ def compute_jpg() -> None: count += 1 -def cli_jpg() -> None: - """Main function for `jpg` command.""" - directory_statistic(JPG_COMD, JPG_HELP) +def jpg() -> None: + """The main functionality for the `jpg` command.""" + directory_statistic(f"{Command.JPG.cmd}", f"{Command.JPG.help}") ascii_title("processing") time_taken = compute_jpg() ascii_title("completed") diff --git a/mdsanima_cli/commands/logo.py b/mdsanima_cli/core/cmd/logo.py similarity index 78% rename from mdsanima_cli/commands/logo.py rename to mdsanima_cli/core/cmd/logo.py index e7c53cd..16a887c 100644 --- a/mdsanima_cli/commands/logo.py +++ b/mdsanima_cli/core/cmd/logo.py @@ -1,9 +1,6 @@ # Copyright (c) 2023 MDSANIMA - -"""Appendign a logo to all images in the current directory. It operates within a specified folder and can process all -images at once. -""" +"""Append a logo to image. It operates within a specified folder and can process all images at once.""" from __future__ import annotations @@ -12,15 +9,14 @@ from PIL import Image -from mdsanima_cli.commands.check import directory_statistic -from mdsanima_cli.parser import LOGO_COMD -from mdsanima_cli.parser import LOGO_HELP -from mdsanima_cli.utils.ascii import ascii_title -from mdsanima_cli.utils.exif import get_exif_bytes -from mdsanima_cli.utils.print import print_cli_data -from mdsanima_cli.utils.print import print_cli_done -from mdsanima_cli.utils.print import print_cli_proc -from mdsanima_cli.utils.timer import timer +from mdsanima_cli.core.cli import Command +from mdsanima_cli.core.cmd.check import directory_statistic +from mdsanima_cli.core.utils.ascii import ascii_title +from mdsanima_cli.core.utils.exif import get_exif_bytes +from mdsanima_cli.core.utils.print import print_cli_data +from mdsanima_cli.core.utils.print import print_cli_done +from mdsanima_cli.core.utils.print import print_cli_proc +from mdsanima_cli.core.utils.timer import timer LOGO_PATH = os.path.expanduser("~/.mdsanima-cli/config/img/logo.png") @@ -49,7 +45,7 @@ def append_logo(image_path: str, logo_path: str, new_name: str) -> None: position_y = image_height - new_logo_height # Add exif data. - exif_bytes = get_exif_bytes(LOGO_HELP) + exif_bytes = get_exif_bytes(f"{Command.LOGO.help}") # Append logo to image and save. image.paste(logo, (position_x, position_y), logo) @@ -89,9 +85,9 @@ def compute_logo() -> None: count += 1 -def cli_logo() -> None: - """Main function for `logo` command.""" - directory_statistic(LOGO_COMD, LOGO_HELP) +def logo() -> None: + """The main functionality for the `logo` command.""" + directory_statistic(f"{Command.LOGO.cmd}", f"{Command.LOGO.help}") try: ascii_title("processing") diff --git a/mdsanima_cli/commands/number.py b/mdsanima_cli/core/cmd/number.py similarity index 76% rename from mdsanima_cli/commands/number.py rename to mdsanima_cli/core/cmd/number.py index 4f26f81..9869a78 100644 --- a/mdsanima_cli/commands/number.py +++ b/mdsanima_cli/core/cmd/number.py @@ -1,6 +1,5 @@ # Copyright (c) 2023 MDSANIMA - """Renaming all images file in current directory to sequential number name.""" @@ -9,13 +8,12 @@ import os import shutil -from mdsanima_cli.commands.check import directory_statistic -from mdsanima_cli.parser import NUMBER_COMD -from mdsanima_cli.parser import NUMBER_HELP -from mdsanima_cli.utils.ascii import ascii_title -from mdsanima_cli.utils.print import print_cli_done -from mdsanima_cli.utils.print import print_cli_proc -from mdsanima_cli.utils.timer import timer +from mdsanima_cli.core.cli import Command +from mdsanima_cli.core.cmd.check import directory_statistic +from mdsanima_cli.core.utils.ascii import ascii_title +from mdsanima_cli.core.utils.print import print_cli_done +from mdsanima_cli.core.utils.print import print_cli_proc +from mdsanima_cli.core.utils.timer import timer @timer @@ -59,9 +57,9 @@ def compute_seq_number() -> None: count += 1 -def cli_number() -> None: - """Main function for `number` command.""" - directory_statistic(NUMBER_COMD, NUMBER_HELP) +def number() -> None: + """The main functionality for the `number` command.""" + directory_statistic(f"{Command.NUMBER.cmd}", f"{Command.NUMBER.help}") ascii_title("processing") time_taken = compute_seq_number() ascii_title("completed") diff --git a/mdsanima_cli/commands/pixelart.py b/mdsanima_cli/core/cmd/pixelart.py similarity index 80% rename from mdsanima_cli/commands/pixelart.py rename to mdsanima_cli/core/cmd/pixelart.py index 9625b5c..56960b9 100644 --- a/mdsanima_cli/commands/pixelart.py +++ b/mdsanima_cli/core/cmd/pixelart.py @@ -1,6 +1,5 @@ # Copyright (c) 2023 MDSANIMA - """Generating images into pixel art. It operates within a specified folder and can process all images at once. The first step is to open the original image, scale it to 32 pixels, scale it back to its original size, and then save it. """ @@ -12,14 +11,13 @@ from PIL import Image -from mdsanima_cli.commands.check import directory_statistic -from mdsanima_cli.parser import PIXELART_COMD -from mdsanima_cli.parser import PIXELART_HELP -from mdsanima_cli.utils.ascii import ascii_title -from mdsanima_cli.utils.exif import get_exif_bytes -from mdsanima_cli.utils.print import print_cli_done -from mdsanima_cli.utils.print import print_cli_proc -from mdsanima_cli.utils.timer import timer +from mdsanima_cli.core.cli import Command +from mdsanima_cli.core.cmd.check import directory_statistic +from mdsanima_cli.core.utils.ascii import ascii_title +from mdsanima_cli.core.utils.exif import get_exif_bytes +from mdsanima_cli.core.utils.print import print_cli_done +from mdsanima_cli.core.utils.print import print_cli_proc +from mdsanima_cli.core.utils.timer import timer @timer @@ -43,7 +41,7 @@ def generate_pixelart(image_path: str, new_name: str, resolution: int) -> None: result = small_image.resize(image.size, Image.Resampling.NEAREST) # Add exif data. - exif_bytes = get_exif_bytes(PIXELART_HELP) + exif_bytes = get_exif_bytes(f"{Command.PIXELART.help}") # Save the result. result.save(new_name, exif=exif_bytes) @@ -82,9 +80,9 @@ def compute_pixelart() -> None: count += 1 -def cli_pixelart() -> None: - """Main function for `pixelart` command.""" - directory_statistic(PIXELART_COMD, PIXELART_HELP) +def pixelart() -> None: + """The main functionality for the `pixelart` command.""" + directory_statistic(f"{Command.PIXELART.cmd}", f"{Command.PIXELART.help}") ascii_title("processing") time_taken = compute_pixelart() ascii_title("completed") diff --git a/mdsanima_cli/commands/png.py b/mdsanima_cli/core/cmd/png.py similarity index 71% rename from mdsanima_cli/commands/png.py rename to mdsanima_cli/core/cmd/png.py index 3ed41dd..d54aada 100644 --- a/mdsanima_cli/commands/png.py +++ b/mdsanima_cli/core/cmd/png.py @@ -1,9 +1,6 @@ # Copyright (c) 2023 MDSANIMA - -"""Converting images to PNG format from all images in the curreny directory. It operates within a specified folder and -can process all images at once. -""" +"""Convert image to PNG format. It operates within a specified folder and can process all images at once.""" from __future__ import annotations @@ -12,14 +9,13 @@ from PIL import Image -from mdsanima_cli.commands.check import directory_statistic -from mdsanima_cli.parser import PNG_COMD -from mdsanima_cli.parser import PNG_HELP -from mdsanima_cli.utils.ascii import ascii_title -from mdsanima_cli.utils.exif import get_exif_bytes -from mdsanima_cli.utils.print import print_cli_done -from mdsanima_cli.utils.print import print_cli_proc -from mdsanima_cli.utils.timer import timer +from mdsanima_cli.core.cli import Command +from mdsanima_cli.core.cmd.check import directory_statistic +from mdsanima_cli.core.utils.ascii import ascii_title +from mdsanima_cli.core.utils.exif import get_exif_bytes +from mdsanima_cli.core.utils.print import print_cli_done +from mdsanima_cli.core.utils.print import print_cli_proc +from mdsanima_cli.core.utils.timer import timer @timer @@ -30,7 +26,7 @@ def convert_to_png(image_path: str, new_name: str) -> None: image = Image.open(image_path) # Add exif data. - exif_bytes = get_exif_bytes(PNG_HELP) + exif_bytes = get_exif_bytes(f"{Command.PNG.help}") # Save the result. image.save(new_name, "PNG", exif=exif_bytes) @@ -69,9 +65,9 @@ def compute_png() -> None: count += 1 -def cli_png() -> None: - """Main function for `png` command.""" - directory_statistic(PNG_COMD, PNG_HELP) +def png() -> None: + """The main functionality for the `png` command.""" + directory_statistic(f"{Command.PNG.cmd}", f"{Command.PNG.help}") ascii_title("processing") time_taken = compute_png() ascii_title("completed") diff --git a/mdsanima_cli/commands/resize.py b/mdsanima_cli/core/cmd/resize.py similarity index 75% rename from mdsanima_cli/commands/resize.py rename to mdsanima_cli/core/cmd/resize.py index 96f93bd..3d986a7 100644 --- a/mdsanima_cli/commands/resize.py +++ b/mdsanima_cli/core/cmd/resize.py @@ -1,9 +1,6 @@ # Copyright (c) 2023 MDSANIMA - -"""Resizing all images in the curreny directory. It operates within a specified folder and can process all images at -once. -""" +"""Change the width of image to 512 pixels. It operates within a specified folder and can process all images at once.""" from __future__ import annotations @@ -12,14 +9,13 @@ from PIL import Image -from mdsanima_cli.commands.check import directory_statistic -from mdsanima_cli.parser import RESIZE_COMD -from mdsanima_cli.parser import RESIZE_HELP -from mdsanima_cli.utils.ascii import ascii_title -from mdsanima_cli.utils.exif import get_exif_bytes -from mdsanima_cli.utils.print import print_cli_done -from mdsanima_cli.utils.print import print_cli_proc -from mdsanima_cli.utils.timer import timer +from mdsanima_cli.core.cli import Command +from mdsanima_cli.core.cmd.check import directory_statistic +from mdsanima_cli.core.utils.ascii import ascii_title +from mdsanima_cli.core.utils.exif import get_exif_bytes +from mdsanima_cli.core.utils.print import print_cli_done +from mdsanima_cli.core.utils.print import print_cli_proc +from mdsanima_cli.core.utils.timer import timer @timer @@ -42,7 +38,7 @@ def generate_resize(image_path: str, new_name: str, resolution_width: int) -> No image_resized = image.resize(resize_size) # Add exif data. - exif_bytes = get_exif_bytes(RESIZE_HELP) + exif_bytes = get_exif_bytes(f"{Command.RESIZE.help}") # Save the result. image_resized.save(new_name, exif=exif_bytes) @@ -81,9 +77,9 @@ def compute_resize() -> None: count += 1 -def cli_resize() -> None: - """Main function for `resize` command.""" - directory_statistic(RESIZE_COMD, RESIZE_HELP) +def resize() -> None: + """The main functionality for the `resize` command.""" + directory_statistic(f"{Command.RESIZE.cmd}", f"{Command.RESIZE.help}") ascii_title("processing") time_taken = compute_resize() ascii_title("completed") diff --git a/mdsanima_cli/commands/thumbnail.py b/mdsanima_cli/core/cmd/thumbnail.py similarity index 79% rename from mdsanima_cli/commands/thumbnail.py rename to mdsanima_cli/core/cmd/thumbnail.py index c9f4e2e..62209b3 100644 --- a/mdsanima_cli/commands/thumbnail.py +++ b/mdsanima_cli/core/cmd/thumbnail.py @@ -12,14 +12,13 @@ from PIL import Image -from mdsanima_cli.commands.check import directory_statistic -from mdsanima_cli.parser import THUMBNAIL_COMD -from mdsanima_cli.parser import THUMBNAIL_HELP -from mdsanima_cli.utils.ascii import ascii_title -from mdsanima_cli.utils.exif import get_exif_bytes -from mdsanima_cli.utils.print import print_cli_done -from mdsanima_cli.utils.print import print_cli_proc -from mdsanima_cli.utils.timer import timer +from mdsanima_cli.core.cli import Command +from mdsanima_cli.core.cmd.check import directory_statistic +from mdsanima_cli.core.utils.ascii import ascii_title +from mdsanima_cli.core.utils.exif import get_exif_bytes +from mdsanima_cli.core.utils.print import print_cli_done +from mdsanima_cli.core.utils.print import print_cli_proc +from mdsanima_cli.core.utils.timer import timer @timer @@ -39,7 +38,7 @@ def generate_jpeg_thumbnail(image_path: str, new_name: str, resolution: int) -> thumbnail_size = (thumbnail_width, thumbnail_height) # Add exif data. - exif_bytes = get_exif_bytes(THUMBNAIL_HELP) + exif_bytes = get_exif_bytes(f"{Command.THUMBNAIL.help}") # Create JPEG thumbnail and save the result. image.thumbnail(thumbnail_size) @@ -79,9 +78,9 @@ def compute_thumbnail() -> None: count += 1 -def cli_thumbnail() -> None: - """Main function for `thumbnail` command.""" - directory_statistic(THUMBNAIL_COMD, THUMBNAIL_HELP) +def thumbnail() -> None: + """The main functionality for the `thumbnail` command.""" + directory_statistic(f"{Command.THUMBNAIL.cmd}", f"{Command.THUMBNAIL.help}") ascii_title("processing") time_taken = compute_thumbnail() ascii_title("completed") diff --git a/mdsanima_cli/commands/uuids.py b/mdsanima_cli/core/cmd/uuid.py similarity index 66% rename from mdsanima_cli/commands/uuids.py rename to mdsanima_cli/core/cmd/uuid.py index 88b19a1..2b0eea1 100644 --- a/mdsanima_cli/commands/uuids.py +++ b/mdsanima_cli/core/cmd/uuid.py @@ -1,22 +1,20 @@ # Copyright (c) 2023 MDSANIMA - -"""Renaming all images file in current directory to UUID v4 name.""" +"""Rename image files to universally unique identifiers UUID v4 name.""" from __future__ import annotations import os import shutil -import uuid +import uuid as unique -from mdsanima_cli.commands.check import directory_statistic -from mdsanima_cli.parser import UUID_COMD -from mdsanima_cli.parser import UUID_HELP -from mdsanima_cli.utils.ascii import ascii_title -from mdsanima_cli.utils.print import print_cli_done -from mdsanima_cli.utils.print import print_cli_proc -from mdsanima_cli.utils.timer import timer +from mdsanima_cli.core.cli import Command +from mdsanima_cli.core.cmd.check import directory_statistic +from mdsanima_cli.core.utils.ascii import ascii_title +from mdsanima_cli.core.utils.print import print_cli_done +from mdsanima_cli.core.utils.print import print_cli_proc +from mdsanima_cli.core.utils.timer import timer @timer @@ -29,7 +27,7 @@ def rename_to_uuid(image_path: str, new_name: str) -> None: @timer def compute_uuid() -> None: - """Renaming all images file to UUID in the current directory. + """Renaming all image files to UUID v4 name inside the current directory. Example file name: `9c569045-a69f-4a26-b0b5-c3b06dd9052c.jpg` """ @@ -45,7 +43,7 @@ def compute_uuid() -> None: # Checking extension and rename images in directory. for file in directory: - uuidv4 = str(uuid.uuid4()) + uuidv4 = str(unique.uuid4()) if file.endswith(png): new_name = uuidv4 + png time_taken = rename_to_uuid(file, new_name) @@ -61,9 +59,9 @@ def compute_uuid() -> None: count += 1 -def cli_uuid() -> None: - """Main function for `uuid` command.""" - directory_statistic(UUID_COMD, UUID_HELP) +def uuid() -> None: + """The main functionality for the `uuid` command.""" + directory_statistic(f"{Command.UUID.cmd}", f"{Command.UUID.help}") ascii_title("processing") time_taken = compute_uuid() ascii_title("completed") diff --git a/mdsanima_cli/commands/watermark.py b/mdsanima_cli/core/cmd/watermark.py similarity index 81% rename from mdsanima_cli/commands/watermark.py rename to mdsanima_cli/core/cmd/watermark.py index fcdba42..36ed376 100644 --- a/mdsanima_cli/commands/watermark.py +++ b/mdsanima_cli/core/cmd/watermark.py @@ -1,9 +1,6 @@ # Copyright (c) 2023 MDSANIMA - -"""This module is designed to adding a watermark to all images in the current directory. It operates within a specified -folder and can process all images at once. -""" +"""Append a watermark to image. It operates within a specified folder and can process all images at once.""" from __future__ import annotations @@ -12,15 +9,14 @@ from PIL import Image -from mdsanima_cli.commands.check import directory_statistic -from mdsanima_cli.parser import WATERMARK_COMD -from mdsanima_cli.parser import WATERMARK_HELP -from mdsanima_cli.utils.ascii import ascii_title -from mdsanima_cli.utils.exif import get_exif_bytes -from mdsanima_cli.utils.print import print_cli_data -from mdsanima_cli.utils.print import print_cli_done -from mdsanima_cli.utils.print import print_cli_proc -from mdsanima_cli.utils.timer import timer +from mdsanima_cli.core.cli import Command +from mdsanima_cli.core.cmd.check import directory_statistic +from mdsanima_cli.core.utils.ascii import ascii_title +from mdsanima_cli.core.utils.exif import get_exif_bytes +from mdsanima_cli.core.utils.print import print_cli_data +from mdsanima_cli.core.utils.print import print_cli_done +from mdsanima_cli.core.utils.print import print_cli_proc +from mdsanima_cli.core.utils.timer import timer WATERMARK_PATH = os.path.expanduser("~/.mdsanima-cli/config/img/watermark.png") @@ -71,7 +67,7 @@ def append_watermark(image_path: str, waterm_path: str, new_name: str) -> None: image.paste(watermark_bg, (width, height), watermark_bg) # Add exif data. - exif_bytes = get_exif_bytes(WATERMARK_HELP) + exif_bytes = get_exif_bytes(f"{Command.WATERMARK.help}") # Save the result. image.save(new_name, exif=exif_bytes) @@ -110,9 +106,9 @@ def compute_watermark() -> None: count += 1 -def cli_watermark() -> None: - """Main function for `watermark` command.""" - directory_statistic(WATERMARK_COMD, WATERMARK_HELP) +def watermark() -> None: + """The main functionality for the `watermark` command.""" + directory_statistic(f"{Command.WATERMARK.cmd}", f"{Command.WATERMARK.help}") try: ascii_title("processing") diff --git a/mdsanima_cli/commands/webp.py b/mdsanima_cli/core/cmd/webp.py similarity index 71% rename from mdsanima_cli/commands/webp.py rename to mdsanima_cli/core/cmd/webp.py index e165d91..190cb7b 100644 --- a/mdsanima_cli/commands/webp.py +++ b/mdsanima_cli/core/cmd/webp.py @@ -1,9 +1,6 @@ # Copyright (c) 2023 MDSANIMA - -"""Converting images to WebP format from all images in the curreny directory. It operates within a specified folder and -can process all images at once. -""" +"""Convert image to WebP format. It operates within a specified folder and can process all images at once.""" from __future__ import annotations @@ -12,14 +9,13 @@ from PIL import Image -from mdsanima_cli.commands.check import directory_statistic -from mdsanima_cli.parser import WEBP_COMD -from mdsanima_cli.parser import WEBP_HELP -from mdsanima_cli.utils.ascii import ascii_title -from mdsanima_cli.utils.exif import get_exif_bytes -from mdsanima_cli.utils.print import print_cli_done -from mdsanima_cli.utils.print import print_cli_proc -from mdsanima_cli.utils.timer import timer +from mdsanima_cli.core.cli import Command +from mdsanima_cli.core.cmd.check import directory_statistic +from mdsanima_cli.core.utils.ascii import ascii_title +from mdsanima_cli.core.utils.exif import get_exif_bytes +from mdsanima_cli.core.utils.print import print_cli_done +from mdsanima_cli.core.utils.print import print_cli_proc +from mdsanima_cli.core.utils.timer import timer @timer @@ -30,7 +26,7 @@ def convert_to_webp(image_path: str, new_name: str) -> None: image = Image.open(image_path) # Add exif data. - exif_bytes = get_exif_bytes(WEBP_HELP) + exif_bytes = get_exif_bytes(f"{Command.WEBP.help}") # Save the result. image.save(new_name, exif=exif_bytes) @@ -69,9 +65,9 @@ def compute_webp() -> None: count += 1 -def cli_webp() -> None: - """Main function for `webp` command.""" - directory_statistic(WEBP_COMD, WEBP_HELP) +def webp() -> None: + """The main functionality for the `webp` command.""" + directory_statistic(f"{Command.WEBP.cmd}", f"{Command.WEBP.help}") ascii_title("processing") time_taken = compute_webp() ascii_title("completed") diff --git a/mdsanima_cli/utils/ascii.py b/mdsanima_cli/core/utils/ascii.py similarity index 100% rename from mdsanima_cli/utils/ascii.py rename to mdsanima_cli/core/utils/ascii.py diff --git a/mdsanima_cli/utils/exif.py b/mdsanima_cli/core/utils/exif.py similarity index 100% rename from mdsanima_cli/utils/exif.py rename to mdsanima_cli/core/utils/exif.py diff --git a/mdsanima_cli/utils/print.py b/mdsanima_cli/core/utils/print.py similarity index 100% rename from mdsanima_cli/utils/print.py rename to mdsanima_cli/core/utils/print.py diff --git a/mdsanima_cli/utils/stats.py b/mdsanima_cli/core/utils/stats.py similarity index 100% rename from mdsanima_cli/utils/stats.py rename to mdsanima_cli/core/utils/stats.py diff --git a/mdsanima_cli/utils/timer.py b/mdsanima_cli/core/utils/timer.py similarity index 100% rename from mdsanima_cli/utils/timer.py rename to mdsanima_cli/core/utils/timer.py diff --git a/mdsanima_cli/parser.py b/mdsanima_cli/parser.py deleted file mode 100644 index ed647e9..0000000 --- a/mdsanima_cli/parser.py +++ /dev/null @@ -1,136 +0,0 @@ -# Copyright (c) 2023 MDSANIMA - - -"""This is a functionality for parsing arguments in command-line tools.""" - - -from __future__ import annotations - -import argparse -from typing import Final - -from mdsanima_cli._version import __version__ - - -PROG: Final[str] = "mdsanima" -DESC: Final[str] = "MDSANIMA CLI is a command-line interface for image processing." -EPIL: Final[str] = "Copyright \U000000A9 2023 MDSANIMA" - -ALL_IMAGES_DIR: Final[str] = "all images file inside the current directory." -SUBPERSER_DESC: Final[str] = f"All commands execute on {ALL_IMAGES_DIR}" - -CHECK_COMD: Final[str] = "check" -CHECK_DESC: Final[str] = f"Print statistic info about {ALL_IMAGES_DIR}" -CHECK_HELP: Final[str] = "print directory info" - -UUID_COMD: Final[str] = "uuid" -UUID_DESC: Final[str] = f"Rename to UUID {ALL_IMAGES_DIR}" -UUID_HELP: Final[str] = "rename to uuid" - -NUMBER_COMD: Final[str] = "number" -NUMBER_DESC: Final[str] = f"Rename to sequential numbers {ALL_IMAGES_DIR}" -NUMBER_HELP: Final[str] = "rename to seq numbers" - -LOGO_COMD: Final[str] = "logo" -LOGO_DESC: Final[str] = f"Append a logo to {ALL_IMAGES_DIR}" -LOGO_HELP: Final[str] = "append a logo" - -WATERMARK_COMD: Final[str] = "watermark" -WATERMARK_DESC: Final[str] = f"Append a watermark to {ALL_IMAGES_DIR}" -WATERMARK_HELP: Final[str] = "append a watermark" - -JPG_COMD: Final[str] = "jpg" -JPG_DESC: Final[str] = f"Convert to JPG format {ALL_IMAGES_DIR}" -JPG_HELP: Final[str] = "convert to jpg" - -PNG_COMD: Final[str] = "png" -PNG_DESC: Final[str] = f"Convert to PNG format {ALL_IMAGES_DIR}" -PNG_HELP: Final[str] = "convert to png" - -WEBP_COMD: Final[str] = "webp" -WEBP_DESC: Final[str] = f"Convert to WebP format {ALL_IMAGES_DIR}" -WEBP_HELP: Final[str] = "convert to webp" - -PIXELART_COMD: Final[str] = "pixelart" -PIXELART_DESC: Final[str] = f"Generate pixel art 32px from {ALL_IMAGES_DIR}" -PIXELART_HELP: Final[str] = "generate pixel art 32px" - -GRID_COMD: Final[str] = "grid" -GRID_DESC: Final[str] = f"Generate grid 2x2 from {ALL_IMAGES_DIR}" -GRID_HELP: Final[str] = "generate grid 2x2" - -THUMBNAIL_COMD: Final[str] = "thumbnail" -THUMBNAIL_DESC: Final[str] = f"Generate JPEG thumbnails 128px from {ALL_IMAGES_DIR}" -THUMBNAIL_HELP: Final[str] = "generate jpeg thumbnail 128px" - -GIFMAKER_COMD: Final[str] = "gifmaker" -GIFMAKER_DESC: Final[str] = f"Generate GIF animation pixel art from {ALL_IMAGES_DIR}" -GIFMAKER_HELP: Final[str] = "generate gif animation pixel art" - -RESIZE_COMD: Final[str] = "resize" -RESIZE_DESC: Final[str] = f"Resizing to 512px width from {ALL_IMAGES_DIR}" -RESIZE_HELP: Final[str] = "resizing to 512px width" - - -def create_parser() -> None: - """Creates an argument parser for all available functions in this package.""" - - # Create top level parser for mdsanima command. - help_formatter = argparse.RawTextHelpFormatter - parser = argparse.ArgumentParser(prog=PROG, description=DESC, epilog=EPIL, formatter_class=help_formatter) - parser.add_argument("-v", "--version", action="version", version="%(prog)s-cli " + __version__) - subparser = parser.add_subparsers(title="commands", description=SUBPERSER_DESC) - - # Create subparser for check command. - check = subparser.add_parser(name=CHECK_COMD, description=CHECK_DESC, help=CHECK_HELP, epilog=EPIL) - check.set_defaults(command=CHECK_COMD) - - # Create subparser for uuid command. - uuid = subparser.add_parser(name=UUID_COMD, description=UUID_DESC, help=UUID_HELP, epilog=EPIL) - uuid.set_defaults(command=UUID_COMD) - - # Create subparser for number command. - number = subparser.add_parser(name=NUMBER_COMD, description=NUMBER_DESC, help=NUMBER_HELP, epilog=EPIL) - number.set_defaults(command=NUMBER_COMD) - - # Create subparser for logo command. - logo = subparser.add_parser(name=LOGO_COMD, description=LOGO_DESC, help=LOGO_HELP, epilog=EPIL) - logo.set_defaults(command=LOGO_COMD) - - # Create subparser for watermark command. - watermark = subparser.add_parser(name=WATERMARK_COMD, description=WATERMARK_DESC, help=WATERMARK_HELP, epilog=EPIL) - watermark.set_defaults(command=WATERMARK_COMD) - - # Create subparser for jpg command. - jpg = subparser.add_parser(name=JPG_COMD, description=JPG_DESC, help=JPG_HELP, epilog=EPIL) - jpg.set_defaults(command=JPG_COMD) - - # Create subparser for png command. - png = subparser.add_parser(name=PNG_COMD, description=PNG_DESC, help=PNG_HELP, epilog=EPIL) - png.set_defaults(command=PNG_COMD) - - # Create subparser for webp command. - webp = subparser.add_parser(name=WEBP_COMD, description=WEBP_DESC, help=WEBP_HELP, epilog=EPIL) - webp.set_defaults(command=WEBP_COMD) - - # Create subparser for pixelart command. - pixelart = subparser.add_parser(name=PIXELART_COMD, description=PIXELART_DESC, help=PIXELART_HELP, epilog=EPIL) - pixelart.set_defaults(command=PIXELART_COMD) - - # Create subparser for grid command. - grid = subparser.add_parser(name=GRID_COMD, description=GRID_DESC, help=GRID_HELP, epilog=EPIL) - grid.set_defaults(command=GRID_COMD) - - # Create subparser for thumbnail command. - thumbnail = subparser.add_parser(name=THUMBNAIL_COMD, description=THUMBNAIL_DESC, help=THUMBNAIL_HELP, epilog=EPIL) - thumbnail.set_defaults(command=THUMBNAIL_COMD) - - # Create subparser for gifmaker command. - gifmaker = subparser.add_parser(name=GIFMAKER_COMD, description=GIFMAKER_DESC, help=GIFMAKER_HELP, epilog=EPIL) - gifmaker.set_defaults(command=GIFMAKER_COMD) - - # Create subparser for resize command. - resize = subparser.add_parser(name=RESIZE_COMD, description=RESIZE_DESC, help=RESIZE_HELP, epilog=EPIL) - resize.set_defaults(command=RESIZE_COMD) - - return parser diff --git a/mdsanima_cli/utils/__init__.py b/mdsanima_cli/utils/__init__.py deleted file mode 100644 index ab8335d..0000000 --- a/mdsanima_cli/utils/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# Copyright (c) 2023 MDSANIMA diff --git a/pyproject.toml b/pyproject.toml index 05b17ed..346c32a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -119,8 +119,8 @@ Tracker = "https://github.com/mdsanima-lab/mdsanima-cli/issues" [project.scripts] -mdsanima = "mdsanima_cli:main_cli" -mds = "mdsanima_cli:main_cli" +mdsanima = "mdsanima_cli:cli" +mds = "mdsanima_cli:cli" [tool.black]