From aea91c62612b3506019d2f573e42ab25dd24152b Mon Sep 17 00:00:00 2001 From: Xananax Date: Sat, 22 Apr 2023 23:06:27 +0200 Subject: [PATCH] cli command --- main_cli.gd | 44 +++++++++++++++++++++++++++++--------------- project.godot | 15 +++++++++++++++ 2 files changed, 44 insertions(+), 15 deletions(-) mode change 100644 => 100755 main_cli.gd diff --git a/main_cli.gd b/main_cli.gd old mode 100644 new mode 100755 index 29f02c2..3311a1f --- a/main_cli.gd +++ b/main_cli.gd @@ -3,32 +3,46 @@ extends SceneTree var config: ConfigManager = preload("res://config_manager.tres") +const valid_commands := ["list", "stop", "start"] + func _init(): var cmd := CMD.new() - for command in ["list", "stop", "start", "current"]: + for command in valid_commands: if cmd.has_argument(command): - call(command) + call(command, cmd.get_argument(command)) return print("no command provided -- exiting") - quit() + help() + quit(1) -func list() -> void: +func help(_show: bool = true) -> void: + print("Valid commands are:") + for command in valid_commands: + prints(" -",command) + + +func list(show_all: bool = true) -> void: var entries := config.timesheet.entries for item in entries: - print(item) + if show_all: + print(item) + else: + if not item.is_closed: + print(item) quit() -func stop() -> void: - if config.timesheet.current_entry: - config.timesheet.close_entry() +func stop(entry_name: String) -> void: + var success := config.timesheet.stop_entry(entry_name) + if success: + print("closed %s"%[entry_name]) + else: + print("could not close %s"%[entry_name]) + quit() -func start() -> void: - pass - - -func current() -> void: - if config.timesheet.current_entry: - print("{name}\t{start_time}\t{end_time}"%config.timesheet.current_entry) +func start(entry_name: String) -> void: + # warning-ignore:return_value_discarded + config.timesheet.add_entry(entry_name) + quit() diff --git a/project.godot b/project.godot index dd12d0e..f2c2b16 100644 --- a/project.godot +++ b/project.godot @@ -69,13 +69,20 @@ _global_script_class_icons={ [application] config/name="Rat Times" +run/main_scene="res://ui/composed_ui.tscn" config/use_custom_user_dir=true config/custom_user_dir_name="rat_times" run/low_processor_mode=true +boot_splash/show_image=false +boot_splash/bg_color=Color( 0.141176, 0.141176, 0.141176, 0 ) config/icon="res://assets/logo.png" config/macos_native_icon="res://build/logo.icns" config/windows_native_icon="res://build/logo.ico" +[debug] + +settings/fps/force_fps=60 + [display] window/size/width=360 @@ -89,6 +96,14 @@ window/handheld/orientation="portrait" window/ios/hide_home_indicator=false window/stretch/aspect="keep" +[gui] + +theme/use_hidpi=true + +[logging] + +file_logging/log_path="user://logs/rat-times.log" + [rendering] quality/driver/driver_name="GLES2"