Better Resource Management
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user