52 lines
1.4 KiB
Go
52 lines
1.4 KiB
Go
// simplegit is the single entry point for the simplegit git-hosting server and
|
|
// its management TUI. The two used to be separate binaries (cmd/daemon and
|
|
// cmd/gitctl); they are now subcommands of one binary.
|
|
//
|
|
// simplegit daemon run the git hosting server (HTTP + SSH + manage)
|
|
// simplegit ctl run the gitctl TUI against the manage port
|
|
// simplegit (no args, or any other subcommand) print help
|
|
//
|
|
// Each subcommand owns its own flag set, so flags are parsed after the
|
|
// subcommand is selected: `simplegit daemon -skip-auth`, `simplegit ctl -manage ...`.
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"simplegit/cmd/daemon"
|
|
"simplegit/cmd/gitctl"
|
|
)
|
|
|
|
func main() {
|
|
args := os.Args[1:]
|
|
if len(args) == 0 {
|
|
printHelp(os.Stdout)
|
|
return
|
|
}
|
|
switch args[0] {
|
|
case "daemon":
|
|
daemon.Run(args[1:])
|
|
case "ctl":
|
|
gitctl.Run(args[1:])
|
|
case "help", "-h", "--help":
|
|
printHelp(os.Stdout)
|
|
default:
|
|
fmt.Fprintf(os.Stderr, "simplegit: unknown subcommand %q\n\n", args[0])
|
|
printHelp(os.Stderr)
|
|
os.Exit(2)
|
|
}
|
|
}
|
|
|
|
func printHelp(w *os.File) {
|
|
fmt.Fprint(w, `simplegit - minimal git hosting server + management TUI
|
|
|
|
Usage:
|
|
simplegit daemon [flags] run the git hosting server (HTTP + SSH + manage)
|
|
simplegit ctl [flags] run the gitctl TUI against the manage port
|
|
simplegit help show this help
|
|
|
|
Run "simplegit daemon -h" or "simplegit ctl -h" for subcommand flags.
|
|
`)
|
|
}
|