2025-09-24 19:35:56 +01:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"strconv"
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
|
|
|
"code.oliverdavies.uk/opdavies/cmd-zet/internal/lib"
|
|
|
|
)
|
|
|
|
|
|
|
|
var editCmd = &cobra.Command{
|
|
|
|
Use: "edit",
|
|
|
|
Aliases: []string{"e"},
|
2025-09-30 00:48:16 +01:00
|
|
|
Short: "Edit a specific zettel",
|
2025-09-30 02:09:40 +01:00
|
|
|
Long: `zet edit|e ID
|
|
|
|
zet edit|e latest
|
|
|
|
`,
|
2025-09-24 19:35:56 +01:00
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
|
|
if len(args) < 1 {
|
|
|
|
fmt.Println("Error: No id provided")
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
2025-09-30 02:09:40 +01:00
|
|
|
var id int
|
|
|
|
|
|
|
|
if args[0] == "latest" {
|
|
|
|
id = lib.GetLatestZet()
|
|
|
|
} else {
|
|
|
|
i, err := strconv.Atoi(args[0])
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
id = i
|
2025-09-24 19:35:56 +01:00
|
|
|
}
|
|
|
|
|
2025-09-30 02:09:40 +01:00
|
|
|
lib.EditZet(id)
|
2025-09-24 19:35:56 +01:00
|
|
|
},
|
|
|
|
}
|