1// SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
2//
3// SPDX-License-Identifier: AGPL-3.0-or-later
4
5// Package cmd provides the CLI commands for lunatask-mcp-server.
6package cmd
7
8import (
9 "os"
10
11 "github.com/spf13/cobra"
12
13 configcmd "git.sr.ht/~amolith/lunatask-mcp-server/cmd/config"
14)
15
16var version = "dev"
17
18// rootCmd is the base command when called without subcommands.
19//
20//nolint:exhaustruct // cobra only requires a subset of fields
21var rootCmd = &cobra.Command{
22 Use: "lunatask-mcp-server",
23 Short: "MCP server for Lunatask",
24 Long: `lunatask-mcp-server exposes Lunatask to LLMs via the Model Context Protocol.
25
26Use 'lunatask-mcp-server serve' to start the MCP server.
27Use 'lunatask-mcp-server config' to configure the server interactively.`,
28}
29
30func init() {
31 rootCmd.AddCommand(configcmd.Cmd)
32 rootCmd.AddCommand(serveCmd)
33 rootCmd.AddCommand(versionCmd)
34}
35
36//nolint:exhaustruct // cobra only requires a subset of fields
37var versionCmd = &cobra.Command{
38 Use: "version",
39 Short: "Print version information",
40 Run: func(cmd *cobra.Command, _ []string) {
41 _, _ = cmd.OutOrStdout().Write([]byte("lunatask-mcp-server " + version + "\n"))
42 },
43}
44
45// Execute runs the root command.
46func Execute(v string) {
47 version = v
48
49 if err := rootCmd.Execute(); err != nil {
50 os.Exit(1)
51 }
52}
53
54// SetVersion sets the version for display.
55func SetVersion(v string) {
56 version = v
57}