started implementing an API
This commit is contained in:
parent
ef15d4696a
commit
d69af271fe
17
main.gd
17
main.gd
@ -1,20 +1,28 @@
|
|||||||
#!/usr/bin/env -S godot --headless -s
|
#!/usr/bin/env -S godot --headless -s
|
||||||
extends SceneTree
|
extends SceneTree
|
||||||
|
|
||||||
var cmd := CMD.new()
|
var config: ConfigManager = preload("res://config_manager.tres")
|
||||||
|
|
||||||
func _init():
|
func _init():
|
||||||
|
var cmd := CMD.new()
|
||||||
for command in ["list", "stop", "start", "current"]:
|
for command in ["list", "stop", "start", "current"]:
|
||||||
if cmd.has_argument(command):
|
if cmd.has_argument(command):
|
||||||
call(command)
|
call(command)
|
||||||
|
return
|
||||||
|
print("no command provided -- exiting")
|
||||||
|
quit()
|
||||||
|
|
||||||
|
|
||||||
func list() -> void:
|
func list() -> void:
|
||||||
pass
|
var entries := config.timesheet.entries
|
||||||
|
for item in entries:
|
||||||
|
print(item)
|
||||||
|
quit()
|
||||||
|
|
||||||
|
|
||||||
func stop() -> void:
|
func stop() -> void:
|
||||||
pass
|
if config.timesheet.current_entry:
|
||||||
|
config.timesheet.close_entry()
|
||||||
|
|
||||||
|
|
||||||
func start() -> void:
|
func start() -> void:
|
||||||
@ -22,4 +30,5 @@ func start() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func current() -> void:
|
func current() -> void:
|
||||||
pass
|
if config.timesheet.current_entry:
|
||||||
|
print("{name}\t{start_time}\t{end_time}"%config.timesheet.current_entry)
|
||||||
|
@ -7,7 +7,7 @@ class_name CMD
|
|||||||
## unsurround the string
|
## unsurround the string
|
||||||
## This function does no evaluation and does not attempt to guess the type of
|
## This function does no evaluation and does not attempt to guess the type of
|
||||||
## arguments. You will receive either bools, or strings.
|
## 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:
|
var unsurround := func unsurround(value: String, quotes := PackedStringArray(['"', "'"])) -> String:
|
||||||
for quote_str in quotes:
|
for quote_str in quotes:
|
||||||
if value.begins_with(quote_str) \
|
if value.begins_with(quote_str) \
|
||||||
|
@ -75,3 +75,5 @@ func from_csv_line(line: PackedStringArray) -> TimeEntry:
|
|||||||
end_time.from_current_time()
|
end_time.from_current_time()
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
func _to_string() -> String:
|
||||||
|
return "%s\t%s\t%s"%[name, Consts.ONGOING if closed == false else "", start_time]
|
Loading…
Reference in New Issue
Block a user