Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .github/workflows/back-compat-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ on:
- "**/*.go"
- ".github/workflows/back-compat-pr.yml"

permissions:
contents: read

env:
GO_VERSION: '1.24.4'

Expand Down Expand Up @@ -45,5 +42,5 @@ jobs:
- name: Run current version
run: |
/var/tmp/omm_head --db-path=/var/tmp/throwaway.db 'test: a task from PR HEAD'
/var/tmp/omm_head --db-path=/var/tmp/throwaway.db tasks
./.github/scripts/checknumtasks.sh "$(/var/tmp/omm_head --db-path=/var/tmp/throwaway.db tasks | wc -l | xargs)" 2
/var/tmp/omm_head --db-path=/var/tmp/throwaway.db tasks list
./.github/scripts/checknumtasks.sh "$(/var/tmp/omm_head --db-path=/var/tmp/throwaway.db tasks list | wc -l | xargs)" 2
3 changes: 0 additions & 3 deletions .github/workflows/back-compat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ on:
push:
branches: ["main"]

permissions:
contents: read

env:
GO_VERSION: '1.24.4'

Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ on:
- "**/*.go"
- ".github/workflows/build.yml"

permissions:
contents: read

env:
GO_VERSION: '1.24.4'

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Go
Expand All @@ -26,5 +26,3 @@ jobs:
go-version: ${{ env.GO_VERSION }}
- name: go build
run: go build -v ./...
- name: go test
run: go test -v ./...
3 changes: 0 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ on:
- "**/*.go"
- ".github/workflows/lint.yml"

permissions:
contents: read

env:
GO_VERSION: '1.24.4'

Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ on:
- "**/*.go"
- ".github/workflows/run.yml"

permissions:
contents: read

env:
GO_VERSION: '1.24.4'

Expand All @@ -33,5 +30,5 @@ jobs:
run: |
cat assets/sample-tasks.txt | ./omm import
./omm 'test: a task'
./omm tasks
./.github/scripts/checknumtasks.sh "$(./omm tasks | wc -l | xargs)" 11
./omm tasks list
./.github/scripts/checknumtasks.sh "$(./omm tasks list | wc -l | xargs)" 11
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: test

on:
push:
branches: ["main"]
pull_request:
paths:
- "go.*"
- "**/*.go"
- ".github/workflows/test.yml"

env:
GO_VERSION: '1.24.4'

jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: go test
env:
INTEGRATION: "1"
run: go test -v ./...
3 changes: 0 additions & 3 deletions .github/workflows/vulncheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ on:
- "**/*.go"
- ".github/workflows/vulncheck.yml"

permissions:
contents: read

env:
GO_VERSION: '1.24.4'

Expand Down
20 changes: 0 additions & 20 deletions cmd/tasks.go

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
github.com/charmbracelet/glamour v0.10.0
github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834
github.com/dustin/go-humanize v1.0.1
github.com/google/uuid v1.6.0
github.com/muesli/termenv v0.16.0
github.com/spf13/cobra v1.9.1
github.com/spf13/pflag v1.0.6
Expand All @@ -32,7 +33,6 @@ require (
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
113 changes: 94 additions & 19 deletions cmd/root.go → internal/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os"
"path/filepath"
"runtime"
"strconv"
"strings"
"time"

Expand All @@ -32,23 +33,26 @@ const (
defaultDataDirWindows = "AppData/Local"
configFileName = "omm/omm.toml"
dbFileName = "omm/omm.db"
printTasksDefault = 20
numListTasksDefault = 20
taskListTitleMaxLen = 8
)

var (
errCouldntGetHomeDir = errors.New("couldn't get home directory")
errConfigFileExtIncorrect = errors.New("config file must be a TOML file")
errConfigFileDoesntExist = errors.New("config file does not exist")
errDBFileExtIncorrect = errors.New("db file needs to end with .db")
errMaxImportLimitExceeded = errors.New("import limit exceeded")
errNothingToImport = errors.New("nothing to import")
errListDensityIncorrect = errors.New("list density is incorrect; valid values: compact/spacious")
errCouldntCreateDBDirectory = errors.New("couldn't create directory for database")
errCouldntCreateDB = errors.New("couldn't create database")
errCouldntInitializeDB = errors.New("couldn't initialize database")
errCouldntOpenDB = errors.New("couldn't open database")
errCouldntSetupGuide = errors.New("couldn't set up guided walkthrough")
errCouldntGetHomeDir = errors.New("couldn't get home directory")
errConfigFileExtIncorrect = errors.New("config file must be a TOML file")
errConfigFileDoesntExist = errors.New("config file does not exist")
errDBFileExtIncorrect = errors.New("db file needs to end with .db")
errMaxImportLimitExceeded = errors.New("import limit exceeded")
errNothingToImport = errors.New("nothing to import")
errListDensityIncorrect = errors.New("list density is incorrect; valid values: compact/spacious")
errCouldntCreateDBDirectory = errors.New("couldn't create directory for database")
errCouldntCreateDB = errors.New("couldn't create database")
errCouldntInitializeDB = errors.New("couldn't initialize database")
errCouldntOpenDB = errors.New("couldn't open database")
errCouldntSetupGuide = errors.New("couldn't set up guided walkthrough")
errInvalidTaskIndexProvided = errors.New("invalid task index provided")
errInvalidTaskOutputFmtProvided = errors.New("invalid output format provided")
errInvalidTaskStatusFilterProvided = errors.New("invalid status filter provided")

//go:embed assets/CHANGELOG.md
updateContents string
Expand Down Expand Up @@ -134,14 +138,17 @@ func NewRootCommand() (*cobra.Command, error) {
db *sql.DB
taskListColor string
archivedTaskListColor string
printTasksNum uint8
taskListTitle string
listDensityFlagInp string
editorFlagInp string
editorCmd string
showContextFlagInp bool
confirmBeforeDeletion bool
circularNav bool
taskOutputFmtStr string
tasksLimit uint16
tasksOffset uint16
statusFilterStr string
)

rootCmd := &cobra.Command{
Expand Down Expand Up @@ -355,9 +362,62 @@ Sorry for breaking the upgrade step!

tasksCmd := &cobra.Command{
Use: "tasks",
Short: "Output tasks tracked by omm to stdout",
Short: "Interact with tasks tracked by omm",
}

listTasksCmd := &cobra.Command{
Use: "list",
Short: "List tasks",
RunE: func(_ *cobra.Command, _ []string) error {
return printTasks(db, printTasksNum, os.Stdout)
format, ok := parseTaskOutputFormat(taskOutputFmtStr)
if !ok {
return fmt.Errorf("%w; allowed values: %v", errInvalidTaskOutputFmtProvided, taskOutputFormats())
}

statusFilter, ok := types.ParseTaskStatusFilter(statusFilterStr)
if !ok {
return fmt.Errorf("%w; allowed values: %v", errInvalidTaskStatusFilterProvided, types.TaskStatusFilterValues())
}

return listTasks(db, statusFilter, tasksLimit, tasksOffset, format, os.Stdout)
},
}

searchTasksCmd := &cobra.Command{
Use: "search <QUERY>",
Short: "Search tasks based on a query",
Args: cobra.ExactArgs(1),
RunE: func(_ *cobra.Command, args []string) error {
format, ok := parseTaskOutputFormat(taskOutputFmtStr)
if !ok {
return fmt.Errorf("%w; allowed values: %v", errInvalidTaskOutputFmtProvided, taskOutputFormats())
}

statusFilter, ok := types.ParseTaskStatusFilter(statusFilterStr)
if !ok {
return fmt.Errorf("%w; allowed values: %v", errInvalidTaskStatusFilterProvided, types.TaskStatusFilterValues())
}

return searchTasks(db, args[0], statusFilter, tasksLimit, tasksOffset, format, os.Stdout)
},
}

showTaskCmd := &cobra.Command{
Use: "show <INDEX>",
Short: "Show details for the task at a specific position in omm's list",
Args: cobra.ExactArgs(1),
RunE: func(_ *cobra.Command, args []string) error {
index, err := strconv.ParseUint(args[0], 10, 0)
if err != nil || index == 0 {
return fmt.Errorf("%w; value needs to be an integer >= 1", errInvalidTaskIndexProvided)
}

format, ok := parseTaskOutputFormat(taskOutputFmtStr)
if !ok {
return fmt.Errorf("%w; allowed values: %v", errInvalidTaskOutputFmtProvided, taskOutputFormats())
}

return showTask(db, index, format, os.Stdout)
},
}

Expand Down Expand Up @@ -447,15 +507,30 @@ Sorry for breaking the upgrade step!
rootCmd.Flags().BoolVar(&confirmBeforeDeletion, "confirm-before-deletion", true, "whether to ask for confirmation before deleting a task")
rootCmd.Flags().BoolVar(&circularNav, "circular-nav", false, "whether to enable circular navigation for lists (cycle back to the first entry from the last, and vice versa)")

tasksCmd.Flags().Uint8VarP(&printTasksNum, "num", "n", printTasksDefault, "number of tasks to print")
tasksCmd.Flags().StringVarP(&configPath, "config-path", "c", defaultConfigPath, fmt.Sprintf("location of omm's TOML config file%s", configPathAdditionalCxt))
tasksCmd.Flags().StringVarP(&dbPath, "db-path", "d", defaultDBPath, fmt.Sprintf("location of omm's database file%s", dbPathAdditionalCxt))
tasksCmd.PersistentFlags().StringVarP(&configPath, "config-path", "c", defaultConfigPath, fmt.Sprintf("location of omm's TOML config file%s", configPathAdditionalCxt))
tasksCmd.PersistentFlags().StringVarP(&dbPath, "db-path", "d", defaultDBPath, fmt.Sprintf("location of omm's database file%s", dbPathAdditionalCxt))

listTasksCmd.Flags().StringVarP(&taskOutputFmtStr, "format", "f", "plain", fmt.Sprintf("output format to use, possible values: %v", taskOutputFormats()))
listTasksCmd.Flags().Uint16VarP(&tasksLimit, "limit", "l", numListTasksDefault, "number of tasks to list")
listTasksCmd.Flags().Uint16VarP(&tasksOffset, "offset", "o", 0, "offset to use")
listTasksCmd.Flags().StringVarP(&statusFilterStr, "status", "s", "active", fmt.Sprintf("status to use as a filter; possible values: %v", types.TaskStatusFilterValues()))

showTaskCmd.Flags().StringVarP(&taskOutputFmtStr, "format", "f", "plain", fmt.Sprintf("output format to use, possible values: %v", taskOutputFormats()))

searchTasksCmd.Flags().StringVarP(&taskOutputFmtStr, "format", "f", "plain", fmt.Sprintf("output format to use, possible values: %v", taskOutputFormats()))
searchTasksCmd.Flags().Uint16VarP(&tasksLimit, "limit", "l", numListTasksDefault, "number of tasks to list")
searchTasksCmd.Flags().Uint16VarP(&tasksOffset, "offset", "o", 0, "offset to use")
searchTasksCmd.Flags().StringVarP(&statusFilterStr, "status", "s", "active", fmt.Sprintf("status to use as a filter; possible values: %v", types.TaskStatusFilterValues()))

importCmd.Flags().StringVarP(&configPath, "config-path", "c", defaultConfigPath, fmt.Sprintf("location of omm's TOML config file%s", configPathAdditionalCxt))
importCmd.Flags().StringVarP(&dbPath, "db-path", "d", defaultDBPath, fmt.Sprintf("location of omm's database file%s", dbPathAdditionalCxt))

guideCmd.Flags().StringVar(&editorFlagInp, "editor", "vi", "editor command to run when adding/editing context to a task")

tasksCmd.AddCommand(listTasksCmd)
tasksCmd.AddCommand(searchTasksCmd)
tasksCmd.AddCommand(showTaskCmd)

rootCmd.AddCommand(importCmd)
rootCmd.AddCommand(tasksCmd)
rootCmd.AddCommand(guideCmd)
Expand Down
Loading