Compare commits
No commits in common. "dfbd324e0d53a94fa93c7aff7ed7a942cd4e925d" and "7edd412b2b9cfdb6b43d4158bf0fd3e9e6a3ecb3" have entirely different histories.
dfbd324e0d
...
7edd412b2b
3 changed files with 17 additions and 59 deletions
1
.envrc
1
.envrc
|
|
@ -1,2 +1 @@
|
||||||
watch_file shell.nix
|
|
||||||
use flake
|
use flake
|
||||||
|
|
|
||||||
46
main.go
46
main.go
|
|
@ -1,15 +1,10 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"errors"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
@ -19,12 +14,10 @@ func main() {
|
||||||
|
|
||||||
func ParseFlags(sb string) {
|
func ParseFlags(sb string) {
|
||||||
note := sb + "/notes"
|
note := sb + "/notes"
|
||||||
daily := sb + "/periodic/daily"
|
// daily := sb + "/periodic/daily"
|
||||||
templates := sb + "/templates"
|
// templates := sb + "/templates"
|
||||||
|
|
||||||
quickPtr := flag.Bool("q", false, "Open quick file for notes")
|
quickPtr := flag.Bool("q", false, "Open quick file for notes")
|
||||||
listPtr := flag.Bool("l", false, "List files in notes directory")
|
|
||||||
dailyPtr := flag.Bool("d", false, "Create/Edit daily journal entry")
|
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
|
@ -36,41 +29,6 @@ func ParseFlags(sb string) {
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if *listPtr {
|
|
||||||
files, err := os.ReadDir(note)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, f := range files {
|
|
||||||
file := f.Name()
|
|
||||||
fmt.Println(strings.ReplaceAll(file, ".md", ""))
|
|
||||||
}
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
if *dailyPtr {
|
|
||||||
date := time.Now().Local().Format("2006-01-02")
|
|
||||||
file := daily + "/" + date + ".md"
|
|
||||||
dailyTemplate := templates + "/daily.md"
|
|
||||||
|
|
||||||
// If the file doesn't exist, create it
|
|
||||||
if _, err := os.Stat(file); errors.Is(err, os.ErrNotExist) {
|
|
||||||
// Read template file
|
|
||||||
t, _ := os.ReadFile(dailyTemplate)
|
|
||||||
|
|
||||||
// Replace yesterday and tomorrow with specific dates
|
|
||||||
t = bytes.ReplaceAll(t, []byte("YESTERDAY"), []byte(time.Now().Local().AddDate(0, 0, -1).Format("2006-01-02")))
|
|
||||||
t = bytes.ReplaceAll(t, []byte("TOMORROW"), []byte(time.Now().Local().AddDate(0, 0, 1).Format("2006-01-02")))
|
|
||||||
|
|
||||||
// write the file
|
|
||||||
os.WriteFile(file, t, 0644)
|
|
||||||
}
|
|
||||||
|
|
||||||
OpenNvim(file)
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(fileName) == 0 {
|
if len(fileName) == 0 {
|
||||||
fmt.Println("You didn't specify a note name")
|
fmt.Println("You didn't specify a note name")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|
|
||||||
11
shell.nix
11
shell.nix
|
|
@ -12,13 +12,14 @@
|
||||||
),
|
),
|
||||||
mkGoEnv ? pkgs.mkGoEnv,
|
mkGoEnv ? pkgs.mkGoEnv,
|
||||||
gomod2nix ? pkgs.gomod2nix,
|
gomod2nix ? pkgs.gomod2nix,
|
||||||
}: let
|
}:
|
||||||
goEnv = mkGoEnv {pwd = ./.;};
|
|
||||||
|
let
|
||||||
|
goEnv = mkGoEnv { pwd = ./.; };
|
||||||
in
|
in
|
||||||
pkgs.mkShell {
|
pkgs.mkShell {
|
||||||
packages = [
|
packages = [
|
||||||
goEnv
|
goEnv
|
||||||
gomod2nix
|
gomod2nix
|
||||||
pkgs.gopls
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue