Files
python/refit/src/refit.py

59 lines
1.6 KiB
Python
Raw Normal View History

2025-09-27 20:53:07 +02:00
import argparse
import sys
from modules.refit_logger import logger
from modules.refit_create import Refit_Create
2025-09-27 20:53:07 +02:00
2025-09-28 18:05:03 +02:00
from version import GET_VERSION_NUMBER
current_version = GET_VERSION_NUMBER()
2025-09-27 20:53:07 +02:00
# Setting Global Variables
2025-09-28 18:05:03 +02:00
REFIT_VERSION = f"Refit Beta {current_version}"
2025-09-27 20:53:07 +02:00
# ---------------------------ARGPARSE START---------------------------
# Main Parser
parser = argparse.ArgumentParser(
prog="Refit",
description="This is a file and directory manipulation tool.\
it can create, move and delete files and directories as well as \
renaming them",
epilog=REFIT_VERSION,
)
# Main Parser Arguments
# Create Parser
subparser = parser.add_subparsers(
title="Commands",
dest="create",
required=False,
)
# Create Parser Arguments
2025-09-28 17:20:51 +02:00
create_parser = subparser.add_parser("create", help="creates a new file/folder")
2025-09-27 20:53:07 +02:00
create_parser.add_argument("-n", type=int, help="number of items")
create_parser.add_argument("-i", "--input", help="input file")
create_parser.add_argument(
"--name",
nargs="*",
help="the name of the folder you want to create\n Default: directory",
)
create_parser.set_defaults(command_class=Refit_Create)
2025-09-27 20:53:07 +02:00
args = parser.parse_args()
# ---------------------------ARGPARSE END-----------------------------
# Dispatcher
# determines what code gets addressed based of the users choosen flags.
if hasattr(args, "command_class"):
2025-09-27 20:53:07 +02:00
logger.debug("In hasattr()")
Refit_Create = args.command_class
create_command_instance = Refit_Create(args)
create_command_instance()
2025-09-27 20:53:07 +02:00
else:
parser.print_help()
logger.info("No input, exiting with error:1")
sys.exit(1)