Skip to content

Commit

Permalink
feat: initial working setup
Browse files Browse the repository at this point in the history
  • Loading branch information
dhth committed Jul 9, 2024
0 parents commit 853e1b9
Show file tree
Hide file tree
Showing 31 changed files with 2,229 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: build

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

permissions:
contents: read

env:
GO_VERSION: '1.22.5'

jobs:
build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: go build
run: go build -v ./...
- name: go test
run: go test -v ./...
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.58
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: release

on:
push:
tags:
- 'v*'

env:
GO_VERSION: '1.22.5'

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: Build
run: go build -v ./...
- name: Test
run: go test -v ./...
- name: Install Cosign
uses: sigstore/cosign-installer@v3
with:
cosign-release: 'v2.2.3'
- name: Store Cosign private key in a file
run: 'echo "$COSIGN_KEY" > cosign.key'
shell: bash
env:
COSIGN_KEY: ${{secrets.COSIGN_KEY}}
- name: Release Binaries
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{secrets.GH_PAT}}
COSIGN_PASSWORD: ${{secrets.COSIGN_PASSWORD}}
31 changes: 31 additions & 0 deletions .github/workflows/vulncheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: vulncheck
on:
push:
branches: [ "main" ]
pull_request:
paths:
- "go.*"
- "**/*.go"
- ".github/workflows/*.yml"

permissions:
contents: read

env:
GO_VERSION: '1.22.5'

jobs:
vulncheck:
name: vulncheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- name: govulncheck
shell: bash
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
omm
.quickrun
cosign.key
cosign.pub
justfile
.notes
debug.log
tasks.txt
45 changes: 45 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
version: 2

release:
draft: true

before:
hooks:
- go mod tidy
- go generate ./...

builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- darwin

signs:
- cmd: cosign
stdin: "{{ .Env.COSIGN_PASSWORD }}"
args:
- "sign-blob"
- "--key=cosign.key"
- "--output-signature=${signature}"
- "${artifact}"
- "--yes" # needed on cosign 2.0.0+
artifacts: all

brews:
- name: omm
repository:
owner: dhth
name: homebrew-tap
directory: Formula
license: MIT
homepage: "https://github.com/dhth/omm"
description: "omm is a keyboard-driven task manager for the command line"

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
- "^ci:"
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Dhruv Thakur

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
119 changes: 119 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# omm

✨ Overview
---

`omm` (stands for "on-my-mind") is a keyboard-driven task manager for the
command line.

`omm` is intended for those who need to frequently rearrange tasks in their
to-do list. It lets you move any item to the top of the list, add tasks at
specific positions, and adjust task priorities up or down, all via one or two
keypresses.

![Usage](https://tools.dhruvs.space/images/omm/omm.gif)

🤔 Motivation
---

The fundamental idea behind `omm` is that while we might have several tasks on
our to-do list — each with its own priority — we typically focus on one task at
a time. Priorities frequently change, requiring us to switch between tasks.
`omm` lets you visualize this shifting priority order with a very simple list
interface that can be managed entirely via the keyboard.

💾 Installation
---

**go**:

```sh
go install github.com/dhth/omm@latest
```

⚡️ Usage
---

### TUI

`omm`'s TUI allows you to do the following (all with one or two key presses):

- create/update tasks at a specific position in the priority list
- add a task at the start/end of the list
- move a task to the top of the list (indicating that it takes the highest
priority at the moment)
- move task up/down based on changing priorities
- archive/unarchive a task
- view archived tasks
- delete a task

#### Tweaking the TUI

The list colors and the task list title can be changed via CLI flags.

```bash
omm \
--tl-color="#b8bb26" \
--atl-color="#fb4934" \
--title="work"
```

### Importing tasks

Multiple tasks can be imported from `stdin` using the `import` subcommand.

```bash
cat << 'EOF' | omm import
Order new ACME rocket skates
Draw fake tunnel on the canyon wall
Assemble ACME jet-propelled pogo stick
EOF
```

### Adding a single task

When an argument is passed to `omm`, it saves it as a task, instead of opening
up the TUI.

```bash
omm "Install spring-loaded boxing glove"
```

Outputting tasks
---

Tasks can be outputted to `stdout` using the `tasks` subcommand.

```bash
omm tasks
```

Screenshots
---

![Screen 1](https://tools.dhruvs.space/images/omm/omm-1.png)

![Screen 2](https://tools.dhruvs.space/images/omm/omm-2.png)

⌨️ Keymaps
---

```text
j/↓: move cursor down k/↑: move cursor up
o: add task above cursor a: add task below cursor
O: add task at the beginning of list A: add task at the end of list
J: move task one position down K: move task one position up
[2-9]: move task at index "x" to top of list ⏎: move task on cursor to top of list
ctrl+d: archive/unarchive task ctrl+x: delete task
g: go to top of list G: go to end of list
tab: move between views q/esc: go back/quit
```

Acknowledgements
---

`omm` is built using [bubbletea][1], and is released using [goreleaser][2], both
of which are amazing tools.

[1]: https://github.com/charmbracelet/bubbletea
[2]: https://github.com/goreleaser/goreleaser
46 changes: 46 additions & 0 deletions cmd/db.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package cmd

import (
"database/sql"
"time"
)

func getDB(dbpath string) (*sql.DB, error) {
db, err := sql.Open("sqlite", dbpath)
db.SetMaxOpenConns(1)
db.SetMaxIdleConns(1)
return db, err
}

func initDB(db *sql.DB) error {
// these init queries cannot be changed once omm is released; only further
// migrations can be added, which are run when omm sees a difference between
// the values in the db_versions table and latestDBVersion
_, err := db.Exec(`
CREATE TABLE IF NOT EXISTS db_versions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
version INTEGER NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS task (
id INTEGER PRIMARY KEY AUTOINCREMENT,
summary TEXT NOT NULL,
active BOOLEAN NOT NULL DEFAULT true,
created_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE task_sequence (
id INTEGER PRIMARY KEY,
sequence JSON NOT NULL
);
INSERT INTO task_sequence (id, sequence) VALUES (1, '[]');
INSERT INTO db_versions (version, created_at)
VALUES (1, ?);
`, time.Now().UTC())

return err
}
Loading

0 comments on commit 853e1b9

Please sign in to comment.