| 1 | // SPDX-License-Identifier: AGPL-3.0-or-later |
| 2 | |
| 3 | package main |
| 4 | |
| 5 | import ( |
| 6 | "fmt" |
| 7 | "os" |
| 8 | |
| 9 | "github.com/spf13/cobra" |
| 10 | ) |
| 11 | |
| 12 | var rootCmd = &cobra.Command{ |
| 13 | Use: "shithubd", |
| 14 | Short: "shithub server: web, ssh, worker, and admin tooling", |
| 15 | Long: "shithubd is the entrypoint binary for shithub — a feature-complete, AGPL-licensed clone of GitHub.\nSubcommands cover the HTTP web server, the SSH dispatcher, background workers, migrations, and operational helpers.", |
| 16 | SilenceUsage: true, |
| 17 | SilenceErrors: true, |
| 18 | } |
| 19 | |
| 20 | // Execute runs the root command and exits non-zero on error. |
| 21 | func Execute() { |
| 22 | if err := rootCmd.Execute(); err != nil { |
| 23 | fmt.Fprintln(os.Stderr, "shithubd:", err) |
| 24 | os.Exit(1) |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | func init() { |
| 29 | rootCmd.AddCommand(versionCmd) |
| 30 | rootCmd.AddCommand(webCmd) |
| 31 | |
| 32 | // Stubs for subcommands implemented in later sprints. They surface in |
| 33 | // `--help` so the operator-facing interface is discoverable from day one. |
| 34 | rootCmd.AddCommand(stubCmd("migrate", "Run database migrations", "S01")) |
| 35 | rootCmd.AddCommand(stubCmd("seed", "Load development seed data", "S01")) |
| 36 | rootCmd.AddCommand(stubCmd("worker", "Run background workers", "S14")) |
| 37 | rootCmd.AddCommand(stubCmd("ssh-authkeys", "AuthorizedKeysCommand handler", "S07")) |
| 38 | rootCmd.AddCommand(stubCmd("ssh-shell", "Forced SSH shell dispatcher", "S07/S13")) |
| 39 | rootCmd.AddCommand(stubCmd("storage", "Storage health checks", "S04")) |
| 40 | rootCmd.AddCommand(stubCmd("hook", "Git hook entrypoint", "S14")) |
| 41 | rootCmd.AddCommand(stubCmd("admin", "Site-admin CLI", "S34")) |
| 42 | rootCmd.AddCommand(stubCmd("config", "Config introspection", "S03")) |
| 43 | } |
| 44 |