diff --git a/cmd/guide.go b/cmd/guide.go index b9cd3ab..bc166ea 100644 --- a/cmd/guide.go +++ b/cmd/guide.go @@ -13,7 +13,6 @@ import ( ) const ( - codeBlockMarker = "```" guideAssetsPathPrefix = "assets/guide" ) @@ -21,100 +20,41 @@ var ( //go:embed assets/guide/*.md guideFolder embed.FS + guideSummaryRegex = regexp.MustCompile(`[^a-z-]`) + guideEntries = []entry{ - { - "guide: welcome to omm", - true, - }, - { - "domain: tasks", - true, - }, - { - "domain: task state", - true, - }, - { - "domain: an archived task", - false, - }, - { - "domain: task details", - true, - }, - { - "visuals: list density", - true, - }, - { - "visuals: toggling context pane", - true, - }, - { - "actions: adding tasks", - true, - }, - { - "cli: adding a task via the CLI", - true, - }, - { - "cli: importing several tasks via the CLI", - true, - }, - { - "actions: adding context", - true, - }, - { - "actions: filtering tasks", - true, - }, - { - "actions: quick filtering via a list", - true, - }, - { - "domain: task bookmarks", - true, - }, - { - "domain: task priorities", - true, - }, - { - "actions: updating task details", - true, - }, - { - "config: changing the defaults", - true, - }, - { - "config: flags, env vars, and config file", - true, - }, - { - "config: a sample TOML config", - true, - }, - { - "guide: and that's it!", - true, - }, + {summary: "guide: welcome to omm"}, + {summary: "domain: tasks"}, + {summary: "domain: task state"}, + {summary: "domain: an archived task", archived: true}, + {summary: "domain: task details"}, + {summary: "visuals: list density"}, + {summary: "visuals: toggling context pane"}, + {summary: "actions: adding tasks"}, + {summary: "cli: adding a task via the CLI"}, + {summary: "cli: importing several tasks via the CLI"}, + {summary: "actions: adding context"}, + {summary: "actions: filtering tasks"}, + {summary: "actions: quick filtering via a list"}, + {summary: "domain: task bookmarks"}, + {summary: "domain: task priorities"}, + {summary: "actions: updating task details"}, + {summary: "config: changing the defaults"}, + {summary: "config: flags, env vars, and config file"}, + {summary: "config: a sample TOML config"}, + {summary: "guide: and that's it!"}, } ) type entry struct { - summary string - active bool + summary string + archived bool } func getContext(summary string) (string, error) { summary = strings.ToLower(summary) summary = strings.ReplaceAll(summary, " ", "-") - re := regexp.MustCompile(`[^a-z-]`) - fPath := re.ReplaceAllString(summary, "") + fPath := guideSummaryRegex.ReplaceAllString(summary, "") ctxBytes, err := guideFolder.ReadFile(fmt.Sprintf("%s/%s.md", guideAssetsPathPrefix, fPath)) if err != nil { @@ -136,14 +76,16 @@ func insertGuideTasks(db *sql.DB) error { for i, e := range guideEntries { ctxs[i], err = getContext(guideEntries[i].summary) - if err == nil { - tasks[i] = types.Task{ - Summary: e.summary, - Context: &ctxs[i], - Active: e.active, - CreatedAt: now, - UpdatedAt: now, - } + if err != nil { + continue + } + + tasks[i] = types.Task{ + Summary: e.summary, + Context: &ctxs[i], + Active: !e.archived, + CreatedAt: now, + UpdatedAt: now, } }