cli command
This commit is contained in:
parent
b69be6e07c
commit
aea91c6261
42
main_cli.gd
Normal file → Executable file
42
main_cli.gd
Normal file → Executable file
@ -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:
|
||||
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()
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user