Skip to content

Commit cba1c89

Browse files
committed
update readme
1 parent 75d7a6f commit cba1c89

File tree

6 files changed

+34
-7
lines changed

6 files changed

+34
-7
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# TIL-Prompt
2+
3+
TIL-Prompt is an interactive terminal prompt for creating and managing a collection of TIL (Today I Learned) entries.
4+
5+
6+
# Installation
7+
To install from source using golang 1.16
8+
9+
`go install github.com/roryq/til-prompt/cmd/[email protected]`
10+
11+
# Usage
12+
13+
![](demo.gif)
14+
15+
Follow the prompts to save a new TIL entry.
16+
A README.md is regenerated after each save.
17+
18+
# License
19+
[MIT](LICENSE)

main.go renamed to cmd/til/main.go

File renamed without changes.

demo.gif

89.2 KB
Loading

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ require (
88
github.com/charmbracelet/lipgloss v0.2.1
99
github.com/kennygrant/sanitize v1.2.4
1010
github.com/muesli/go-app-paths v0.2.1
11-
github.com/stretchr/testify v1.7.0 // indirect
11+
github.com/stretchr/testify v1.7.0
1212
gopkg.in/yaml.v2 v2.4.0
1313
)

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,14 @@ github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68/go.mod h1:Xk+z4oIW
3333
github.com/muesli/termenv v0.7.2/go.mod h1:ct2L5N2lmix82RaY3bMWwVu/jUFc9Ule0KGDCiKYPh8=
3434
github.com/muesli/termenv v0.8.1 h1:9q230czSP3DHVpkaPDXGp0TOfAwyjyYwXlUCQxQSaBk=
3535
github.com/muesli/termenv v0.8.1/go.mod h1:kzt/D/4a88RoheZmwfqorY3A+tnsSMA9HJC/fQSFKo0=
36-
github.com/oriser/regroup v0.0.0-20201024192559-010c434ff8f3 h1:SIHa1eb8CJDqFu8potgn0n7grPG2cf2WEKekk/nSz5g=
37-
github.com/oriser/regroup v0.0.0-20201024192559-010c434ff8f3/go.mod h1:odkMeLkWS8G6+WP2z3Pn2vkzhPSvBtFhAUYTKXAtZMQ=
3836
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
3937
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
4038
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4139
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
4240
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
4341
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
4442
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
45-
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
4643
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
47-
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
4844
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
4945
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
5046
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=

pkg/tui/tui.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,22 @@ func (m Model) renderFooter(b *strings.Builder) {
208208
b.WriteRune('\n')
209209
}
210210

211-
b.WriteString(textLowStyle.Render("your til will be saved to "))
212-
b.WriteString(textHighStyle.Render(m.generateFilename()))
211+
if m.anyTextWritten() {
212+
b.WriteString(textLowStyle.Render("your til will be saved to "))
213+
b.WriteString(textHighStyle.Render(m.generateFilename()))
214+
} else {
215+
b.WriteString(textLowStyle.Render("nothing to save"))
216+
}
213217
}
214218

219+
func (m Model) anyTextWritten() bool {
220+
for i := range m.inputs {
221+
if m.inputs[i].Value() != "" {
222+
return true
223+
}
224+
}
225+
return false
226+
}
215227
func (m Model) generateFilename() string {
216228
filename := fmt.Sprintf("%s%s%s.md", formatDirectory(m.inputs[2].Value()), today, formatTitle(m.inputs[0].Value()))
217229
return filename

0 commit comments

Comments
 (0)