Re-add the ability to view or edit the latest zet

Signed-off-by: Oliver Davies <oliver@oliverdavies.uk>
This commit is contained in:
Oliver Davies 2025-09-30 02:09:40 +01:00
parent 5a64827825
commit df9fa52c21
3 changed files with 37 additions and 10 deletions

View file

@ -14,19 +14,29 @@ var viewCmd = &cobra.Command{
Use: "view",
Aliases: []string{"v"},
Short: "View a specific zettel",
Long: `zet view|v ID`,
Long: `zet view|v ID
zet view|v latest
`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) < 1 {
fmt.Println("Error: No id provided")
os.Exit(1)
}
idInt, err := strconv.Atoi(args[0])
var id int
if err != nil {
os.Exit(1)
if args[0] == "latest" {
id = lib.GetLatestZet()
} else {
i, err := strconv.Atoi(args[0])
if err != nil {
os.Exit(1)
}
id = i
}
fmt.Println(lib.ViewZet(idInt))
fmt.Println(lib.ViewZet(id))
},
}