1// SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
2//
3// SPDX-License-Identifier: AGPL-3.0-or-later
4
5// Package cmd provides the lune CLI commands.
6package cmd
7
8import (
9 "context"
10 "os"
11
12 "git.secluded.site/lune/cmd/habit"
13 "git.secluded.site/lune/cmd/journal"
14 "git.secluded.site/lune/cmd/note"
15 "git.secluded.site/lune/cmd/person"
16 "git.secluded.site/lune/cmd/task"
17 "github.com/charmbracelet/fang"
18 "github.com/spf13/cobra"
19)
20
21var (
22 version = "dev"
23 commit = "none"
24)
25
26var rootCmd = &cobra.Command{
27 Use: "lune",
28 Short: "A delightful CLI for Lunatask",
29 Long: `lune is a command-line interface for Lunatask, the encrypted
30all-in-one productivity app for tasks, habits, journaling, and more.
31
32Set LUNATASK_API_KEY in your environment to authenticate.`,
33 SilenceUsage: true,
34 SilenceErrors: true,
35}
36
37func init() {
38 rootCmd.AddGroup(&cobra.Group{ID: "resources", Title: "Resources"})
39 rootCmd.AddGroup(&cobra.Group{ID: "shortcuts", Title: "Shortcuts"})
40
41 rootCmd.AddCommand(initCmd)
42 rootCmd.AddCommand(pingCmd)
43
44 rootCmd.AddCommand(task.Cmd)
45 rootCmd.AddCommand(note.Cmd)
46 rootCmd.AddCommand(person.Cmd)
47 rootCmd.AddCommand(journal.Cmd)
48 rootCmd.AddCommand(habit.Cmd)
49
50 rootCmd.AddCommand(addCmd)
51 rootCmd.AddCommand(doneCmd)
52 rootCmd.AddCommand(jrnlCmd)
53}
54
55// Execute runs the root command with Fang styling.
56func Execute(ctx context.Context) error {
57 return fang.Execute(
58 ctx,
59 rootCmd,
60 fang.WithVersion(version),
61 fang.WithCommit(commit),
62 fang.WithNotifySignal(os.Interrupt),
63 )
64}