started implementing an API

This commit is contained in:
xananax prozaxx 2023-03-04 18:07:03 +04:00
parent ef15d4696a
commit d69af271fe
3 changed files with 16 additions and 5 deletions

17
main.gd
View File

@ -1,20 +1,28 @@
#!/usr/bin/env -S godot --headless -s
extends SceneTree
var cmd := CMD.new()
var config: ConfigManager = preload("res://config_manager.tres")
func _init():
var cmd := CMD.new()
for command in ["list", "stop", "start", "current"]:
if cmd.has_argument(command):
call(command)
return
print("no command provided -- exiting")
quit()
func list() -> void:
pass
var entries := config.timesheet.entries
for item in entries:
print(item)
quit()
func stop() -> void:
pass
if config.timesheet.current_entry:
config.timesheet.close_entry()
func start() -> void:
@ -22,4 +30,5 @@ func start() -> void:
func current() -> void:
pass
if config.timesheet.current_entry:
print("{name}\t{start_time}\t{end_time}"%config.timesheet.current_entry)

View File

@ -7,7 +7,7 @@ class_name CMD
## unsurround the string
## This function does no evaluation and does not attempt to guess the type of
## arguments. You will receive either bools, or strings.
var command_line_arguments: Dictionary = (func get_command_line_arguments() -> Dictionary:
var command_line_arguments: Dictionary = (func () -> Dictionary:
var unsurround := func unsurround(value: String, quotes := PackedStringArray(['"', "'"])) -> String:
for quote_str in quotes:
if value.begins_with(quote_str) \

View File

@ -75,3 +75,5 @@ func from_csv_line(line: PackedStringArray) -> TimeEntry:
end_time.from_current_time()
return self
func _to_string() -> String:
return "%s\t%s\t%s"%[name, Consts.ONGOING if closed == false else "", start_time]