added filemode

This commit is contained in:
2025-09-28 19:51:06 +02:00
parent c8bf85cb6a
commit d2041c5355
4 changed files with 41 additions and 6 deletions

View File

@@ -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

View File

@@ -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---------------------------------------------------------"
)

View File

@@ -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()

View File

@@ -1,5 +1,5 @@
[VERSION]
major = 0
minor = 2
patch = 1
patch = 3