Add directory skeleton and CLI entry point with Cobra
- Create internal/{app,config,engine,divert,socks5,bypass,checker,service,tray,procscan,updater} with placeholder doc.go per package.
- Add .gitkeep stubs for internal/frontend, third_party/{windivert,icons}, installer/, .forgejo/workflows/, docs/.
- Implement cmd/drover/main.go: Cobra root with Version/Commit/BuildDate ldflags, --config global flag, and stub subcommands (check, update --check-only, service install/uninstall/start/stop).
- Add github.com/spf13/cobra v1.10.2 dependency.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
// Command drover is the entry point for the Discord proxy CLI.
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// Build-time variables, populated via -ldflags "-X main.Version=... -X main.Commit=... -X main.BuildDate=...".
|
||||
var (
|
||||
Version = "dev"
|
||||
Commit = "dev"
|
||||
BuildDate = "dev"
|
||||
)
|
||||
|
||||
// configPath is the path to the TOML config file, set via the --config global flag.
|
||||
// Reserved for use in later phases.
|
||||
var configPath string
|
||||
|
||||
func main() {
|
||||
if err := newRootCmd().Execute(); err != nil {
|
||||
// Cobra already prints the error; just exit non-zero.
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func newRootCmd() *cobra.Command {
|
||||
root := &cobra.Command{
|
||||
Use: "drover",
|
||||
Short: "Discord proxy via SOCKS5 + WinDivert",
|
||||
Version: fmt.Sprintf("%s (commit %s, built %s)", Version, Commit, BuildDate),
|
||||
SilenceUsage: true,
|
||||
SilenceErrors: false,
|
||||
}
|
||||
|
||||
// Custom version template: "drover-go vX.Y.Z (commit abc1234, built 2026-05-01)".
|
||||
root.SetVersionTemplate(fmt.Sprintf("drover-go v%s (commit %s, built %s)\n", Version, Commit, BuildDate))
|
||||
|
||||
root.PersistentFlags().StringVar(&configPath, "config", "", "path to TOML config file (reserved)")
|
||||
|
||||
root.AddCommand(newCheckCmd())
|
||||
root.AddCommand(newUpdateCmd())
|
||||
root.AddCommand(newServiceCmd())
|
||||
|
||||
return root
|
||||
}
|
||||
|
||||
func newCheckCmd() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "check",
|
||||
Short: "Run the 7-step proxy diagnostic",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
fmt.Fprintln(cmd.OutOrStdout(), "TODO: 7-step diagnostic")
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func newUpdateCmd() *cobra.Command {
|
||||
var checkOnly bool
|
||||
cmd := &cobra.Command{
|
||||
Use: "update",
|
||||
Short: "Self-update via the Forgejo Releases API",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
fmt.Fprintln(cmd.OutOrStdout(), "TODO: update check")
|
||||
_ = checkOnly // wired up for the upcoming implementation
|
||||
return nil
|
||||
},
|
||||
}
|
||||
cmd.Flags().BoolVar(&checkOnly, "check-only", false, "only check for an update, do not apply")
|
||||
return cmd
|
||||
}
|
||||
|
||||
func newServiceCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "service",
|
||||
Short: "Manage the drover Windows service",
|
||||
}
|
||||
for _, name := range []string{"install", "uninstall", "start", "stop"} {
|
||||
name := name
|
||||
cmd.AddCommand(&cobra.Command{
|
||||
Use: name,
|
||||
Short: fmt.Sprintf("%s the drover Windows service", name),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
fmt.Fprintf(cmd.OutOrStdout(), "TODO: service %s\n", name)
|
||||
return nil
|
||||
},
|
||||
})
|
||||
}
|
||||
return cmd
|
||||
}
|
||||
Reference in New Issue
Block a user