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