added better documentation
This commit is contained in:
parent
953342c280
commit
52310a9021
13
project.py
13
project.py
|
@ -19,18 +19,21 @@ def main():
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
config = read_config()
|
config = read_config()
|
||||||
|
# If no config file exists and user does not go into "config mode"
|
||||||
if config is None and args.config is False:
|
if config is None and args.config is False:
|
||||||
sys.exit("No Config available. please run: 'python project.py --config' to set it up")
|
sys.exit("No Config available. please run: 'python project.py --config' to set it up")
|
||||||
|
# add config
|
||||||
elif args.config is True:
|
elif args.config is True:
|
||||||
config = configure()
|
config = configure()
|
||||||
write_config(config)
|
write_config(config)
|
||||||
|
# change ui mode
|
||||||
elif args.m:
|
elif args.m:
|
||||||
config = handle_change_mode(args)
|
config = handle_change_mode(args)
|
||||||
write_config(config)
|
write_config(config)
|
||||||
|
# start terminal ui
|
||||||
elif config["mode"] == "terminal":
|
elif config["mode"] == "terminal":
|
||||||
handle_terminal(args)
|
handle_terminal(args)
|
||||||
|
# start customtkinter ui
|
||||||
elif config["mode"] == "gui":
|
elif config["mode"] == "gui":
|
||||||
# start gui
|
# start gui
|
||||||
try:
|
try:
|
||||||
|
@ -70,9 +73,13 @@ def read_config():
|
||||||
with open(CONFIG_FILE, "r") as f:
|
with open(CONFIG_FILE, "r") as f:
|
||||||
return json.load(f)
|
return json.load(f)
|
||||||
|
|
||||||
|
|
||||||
def write_config(config: dict):
|
def write_config(config: dict):
|
||||||
|
try:
|
||||||
with open(CONFIG_FILE, "w") as config_file:
|
with open(CONFIG_FILE, "w") as config_file:
|
||||||
json.dump(config, config_file, indent=4)
|
json.dump(config, config_file, indent=4)
|
||||||
|
except FileNotFoundError:
|
||||||
|
sys.exit(ERROR_CORRPUTED_CONFIG)
|
||||||
|
|
||||||
def handle_change_mode(args):
|
def handle_change_mode(args):
|
||||||
config = read_config()
|
config = read_config()
|
||||||
|
@ -88,7 +95,7 @@ def handle_change_mode(args):
|
||||||
|
|
||||||
def handle_terminal(args):
|
def handle_terminal(args):
|
||||||
config = read_config()
|
config = read_config()
|
||||||
|
# if a prompt exists
|
||||||
if args.p:
|
if args.p:
|
||||||
try:
|
try:
|
||||||
bot = TerminalBot(args.p, args.f, **config["ollamaConfig"])
|
bot = TerminalBot(args.p, args.f, **config["ollamaConfig"])
|
||||||
|
|
Loading…
Reference in New Issue