root.go

 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/area"
13	"git.secluded.site/lune/cmd/goal"
14	"git.secluded.site/lune/cmd/habit"
15	initcmd "git.secluded.site/lune/cmd/init"
16	"git.secluded.site/lune/cmd/journal"
17	"git.secluded.site/lune/cmd/note"
18	"git.secluded.site/lune/cmd/person"
19	"git.secluded.site/lune/cmd/task"
20	"github.com/charmbracelet/fang"
21	"github.com/spf13/cobra"
22)
23
24var (
25	version = "dev"
26	commit  = "none"
27)
28
29var rootCmd = &cobra.Command{
30	Use:   "lune",
31	Short: "A delightful CLI for Lunatask",
32	Long: `lune is a command-line interface for Lunatask, the encrypted
33all-in-one productivity app for tasks, habits, journaling, and more.
34
35Run 'lune init' to configure your access token and get started.`,
36	SilenceUsage:  true,
37	SilenceErrors: true,
38}
39
40func init() {
41	rootCmd.AddGroup(&cobra.Group{ID: "resources", Title: "Resources"})
42	rootCmd.AddGroup(&cobra.Group{ID: "shortcuts", Title: "Shortcuts"})
43
44	rootCmd.AddCommand(initcmd.Cmd)
45	rootCmd.AddCommand(pingCmd)
46
47	rootCmd.AddCommand(area.Cmd)
48	rootCmd.AddCommand(goal.Cmd)
49	rootCmd.AddCommand(task.Cmd)
50	rootCmd.AddCommand(note.Cmd)
51	rootCmd.AddCommand(person.Cmd)
52	rootCmd.AddCommand(journal.Cmd)
53	rootCmd.AddCommand(habit.Cmd)
54
55	rootCmd.AddCommand(addCmd)
56	rootCmd.AddCommand(doneCmd)
57	rootCmd.AddCommand(jrnlCmd)
58}
59
60// Execute runs the root command with Fang styling.
61func Execute(ctx context.Context) error {
62	return fang.Execute(
63		ctx,
64		rootCmd,
65		fang.WithVersion(version),
66		fang.WithCommit(commit),
67		fang.WithNotifySignal(os.Interrupt),
68	)
69}