diff --git a/refit/README.md b/refit/README.md index b309324..e7cd74e 100644 --- a/refit/README.md +++ b/refit/README.md @@ -15,5 +15,6 @@ ## Changelog +<2025-09-28> V0.2.3 - Added logging for version file and --filemode path to the decider <2025-09-28> V0.2.0 - Added librefit for standard functions <2025-09-28> V0.1.0 - Added the creation of multiple numbered directories in a given directory with the pattern default directory_n diff --git a/refit/src/modules/refit_create.py b/refit/src/modules/refit_create.py index 2306a7f..59631e6 100644 --- a/refit/src/modules/refit_create.py +++ b/refit/src/modules/refit_create.py @@ -23,6 +23,7 @@ class Refit_Create: self.name = args.name self.input = args.input self.n = args.n + self.filemode = args.filemode def create_input_valid(self): """Checks if the input is valid and returns either True or @@ -72,7 +73,10 @@ class Refit_Create: if self.create_input_valid(): logger.debug("valid input -> continue") - self.create_n_folders(self.n, self.input, self.name) + if self.filemode: + logger.debug("filemode active") + else: + self.create_n_folders(self.n, self.input, self.name) logger.debug( "End of run---------------------------------------------------------" ) diff --git a/refit/src/refit.py b/refit/src/refit.py index 40bfc18..5455b9e 100644 --- a/refit/src/refit.py +++ b/refit/src/refit.py @@ -1,15 +1,42 @@ import argparse import sys +import os +import configparser from modules.refit_logger import logger from modules.refit_create import Refit_Create -from version import GET_VERSION_NUMBER -current_version = GET_VERSION_NUMBER() +CONFIG_FILE = "version.cfg" -# Setting Global Variables -REFIT_VERSION = f"Refit Beta {current_version}" + +def read_version_config(): + config = configparser.ConfigParser() + logger.debug("reading config file") + config.read(CONFIG_FILE) + logger.debug("config file read") + + if not os.path.exists(CONFIG_FILE): + logger.error("Could not find path") + return "" + + if "VERSION" not in config: + logger.error("Could not find VERSION in config file") + return "" + + try: + v = config["VERSION"] + major = v.get("major", "0") + minor = v.get("minor", "0") + patch = v.get("patch", "0") + logger.debug(f"output: {major}.{minor}.{patch}") + return f"{major}.{minor}.{patch}" + except Exception: + logger.warning("Couldnt read version") + return "" + + +REFIT_VERSION = f"Refit Beta {read_version_config()}" # ---------------------------ARGPARSE START--------------------------- # Main Parser @@ -39,6 +66,9 @@ create_parser.add_argument( nargs="*", help="the name of the folder you want to create\n Default: directory", ) +create_parser.add_argument( + "--filemode", action="store_true", help="creates files instead of directories" +) create_parser.set_defaults(command_class=Refit_Create) args = parser.parse_args() diff --git a/refit/src/version.cfg b/refit/src/version.cfg index 86753d2..78b493d 100644 --- a/refit/src/version.cfg +++ b/refit/src/version.cfg @@ -1,5 +1,5 @@ [VERSION] major = 0 minor = 2 -patch = 1 +patch = 3