Skip to content

Commit ba84a90

Browse files
committed
feat: put circular navigation behind a flag
Open URIs directly without invoking `tea.ExecProcess`.
1 parent e9f0999 commit ba84a90

File tree

6 files changed

+25
-4
lines changed

6 files changed

+25
-4
lines changed

cmd/assets/guide/config-a-sample-toml-config.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ list_density = "spacious"
99
show_context = false
1010
editor = "vi -u NONE"
1111
confirm_before_deletion = false
12+
circular_nav = true
1213
```

cmd/assets/updates.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
👉 upcoming
2+
• 🔄 URIs with custom schemes are considered as task bookmarks. For example:
3+
• spotify:track:4fVBFyglBhMf0erfF7pBJp
4+
• obsidian://open?vault=VAULT&file=FILE
5+
• 🆕 Circular navigation for lists via "--circular-nav=true"
6+
17
👉 0.4.3
28
• 🔄 omm asks for confirmation before deleting a task. Change this behavior with
39
"--confirm-before-deletion=false"

cmd/root.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ func NewRootCommand() (*cobra.Command, error) {
142142
editorCmd string
143143
showContextFlagInp bool
144144
confirmBeforeDeletion bool
145+
circularNav bool
145146
)
146147

147148
rootCmd := &cobra.Command{
@@ -247,6 +248,7 @@ Tip: Quickly add a task using 'omm "task summary goes here"'.
247248
TextEditorCmd: strings.Fields(editorCmd),
248249
ShowContext: showContextFlagInp,
249250
ConfirmBeforeDeletion: confirmBeforeDeletion,
251+
CircularNav: circularNav,
250252
}
251253

252254
ui.RenderUI(db, config)
@@ -397,6 +399,7 @@ Error: %s`, author, repoIssuesUrl, err)
397399
rootCmd.Flags().StringVar(&editorFlagInp, "editor", "vi", "editor command to run when adding/editing context to a task")
398400
rootCmd.Flags().BoolVar(&showContextFlagInp, "show-context", false, "whether to start omm with a visible task context pane or not; this can later be toggled on/off in the TUI")
399401
rootCmd.Flags().BoolVar(&confirmBeforeDeletion, "confirm-before-deletion", true, "whether to ask for confirmation before deleting a task")
402+
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)")
400403

401404
tasksCmd.Flags().Uint8VarP(&printTasksNum, "num", "n", printTasksDefault, "number of tasks to print")
402405
tasksCmd.Flags().StringVarP(&configPath, "config-path", "c", defaultConfigPath, fmt.Sprintf("location of omm's TOML config file%s", configPathAdditionalCxt))

internal/ui/cmds.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,18 @@ func openURI(uri string) tea.Cmd {
105105
cmd = "xdg-open"
106106
}
107107
c := exec.Command(cmd, append(args, uri)...)
108-
return tea.ExecProcess(c, func(err error) tea.Msg {
108+
err := c.Run()
109+
return func() tea.Msg {
109110
return uriOpenedMsg{uri, err}
110-
})
111+
}
111112
}
112113

113114
func openURIsDarwin(uris []string) tea.Cmd {
114115
c := exec.Command("open", uris...)
115-
return tea.ExecProcess(c, func(err error) tea.Msg {
116+
err := c.Run()
117+
return func() tea.Msg {
116118
return urisOpenedDarwinMsg{uris, err}
117-
})
119+
}
118120
}
119121

120122
func copyContextToClipboard(context string) tea.Cmd {

internal/ui/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ type Config struct {
2323
DBPath string
2424
ShowContext bool
2525
ConfirmBeforeDeletion bool
26+
CircularNav bool
2627
}

internal/ui/update.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,10 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
428428
case "down", "j":
429429
switch m.activeView {
430430
case taskListView, archivedTaskListView, contextBookmarksView, prefixSelectionView:
431+
if !m.cfg.CircularNav {
432+
break
433+
}
434+
431435
// cycle back to top
432436
var list *list.Model
433437
switch m.activeView {
@@ -473,6 +477,10 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
473477
case "up", "k":
474478
switch m.activeView {
475479
case taskListView, archivedTaskListView, contextBookmarksView, prefixSelectionView:
480+
if !m.cfg.CircularNav {
481+
break
482+
}
483+
476484
// cycle to the end
477485
var list *list.Model
478486
switch m.activeView {

0 commit comments

Comments
 (0)