update refit.py with Refit_Create() class
This commit is contained in:
@@ -2,25 +2,12 @@ import argparse
|
||||
import sys
|
||||
|
||||
from modules.refit_logger import logger
|
||||
|
||||
from modules.refit_create import Refit_Create
|
||||
|
||||
# Setting Global Variables
|
||||
REFIT_VERSION = "Refit Beta 0.0.0"
|
||||
|
||||
|
||||
# ---------------------------BEGIN FUNCTIONS---------------------------
|
||||
# will be in seperate file at some point
|
||||
def refit_create(args):
|
||||
logger.info("Running in create mode")
|
||||
logger.debug(f"Arguments: {args}")
|
||||
print(f"executing on {args.input}")
|
||||
|
||||
|
||||
# ----------------------------END FUNCTIONS----------------------------
|
||||
|
||||
|
||||
# ---------------------------ARGPARSE START---------------------------
|
||||
|
||||
# Main Parser
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="Refit",
|
||||
@@ -46,16 +33,24 @@ create_parser = subparser.add_parser(
|
||||
)
|
||||
create_parser.add_argument("-n", type=int, help="number of items")
|
||||
create_parser.add_argument("-i", "--input", help="input file")
|
||||
create_parser.set_defaults(func=refit_create)
|
||||
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)
|
||||
|
||||
args = parser.parse_args()
|
||||
# ---------------------------ARGPARSE END-----------------------------
|
||||
|
||||
|
||||
# Dispatcher
|
||||
if hasattr(args, "func"):
|
||||
# determines what code gets addressed based of the users choosen flags.
|
||||
if hasattr(args, "command_class"):
|
||||
logger.debug("In hasattr()")
|
||||
args.func(args)
|
||||
Refit_Create = args.command_class
|
||||
create_command_instance = Refit_Create(args)
|
||||
create_command_instance()
|
||||
else:
|
||||
parser.print_help()
|
||||
logger.info("No input, exiting with error:1")
|
||||
|
||||
Reference in New Issue
Block a user