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