Better Resource Management

This commit is contained in:
2019-02-26 13:22:37 -06:00
parent 427468c6a8
commit dbf94a42a2
6 changed files with 190 additions and 22 deletions
+11
View File
@@ -20,10 +20,17 @@ type AppState struct {
ValidOperations map[string][]string
OpFuncs map[string]func([]string) int
mode ResourceId
TaskList *todotxt.TaskList
DoneList *todotxt.TaskList
taskListLoaded bool
doneListLoaded bool
screens []Screen
lang *Translator
}
func NewApp() *AppState {
@@ -41,8 +48,10 @@ func NewApp() *AppState {
func (a *AppState) run(parms []string) int {
if len(parms) == 0 || parms[0] == "ui" {
// UI Mode
a.mode = ResModeUI
return uiLoop()
}
a.mode = ResModeCLI
if fn, ok := a.OpFuncs[parms[0]]; ok {
return fn(parms[1:])
}
@@ -117,6 +126,8 @@ func (a *AppState) migrate(from, to int) int {
}
func (a *AppState) initialize() {
a.initLanguage()
var err error
a.config, err = userConfig.NewConfig(a.Name)
if err != nil {