this seems fine

trunk
vilmibm 2021-01-21 23:47:10 +00:00
parent 0353e2d704
commit b8e66a1924
1 changed files with 7 additions and 13 deletions

20
main.go
View File

@ -16,19 +16,13 @@ import (
const binroot = "/town/commands" const binroot = "/town/commands"
var rootCmd = &cobra.Command{ var rootCmd = &cobra.Command{
Use: "town", Use: "town",
Short: "Run commands unique to tilde.town", Short: "Run commands unique to tilde.town",
DisableFlagParsing: true,
}
func init() {
rootCmd.Flags().BoolP("help", "h", false, "")
} }
var adminCmd = &cobra.Command{ var adminCmd = &cobra.Command{
Use: "admin", Use: "admin",
Short: "Run administrative commands", Short: "Run administrative commands",
DisableFlagParsing: true,
} }
func isAdmin() (bool, error) { func isAdmin() (bool, error) {
@ -109,8 +103,9 @@ func parseCommand(targetCmd *cobra.Command, yamlPath string) {
} }
parsedCmd := &cobra.Command{ parsedCmd := &cobra.Command{
Use: filepath.Base(executablePath), Use: filepath.Base(executablePath),
RunE: execWrapper(executablePath), RunE: execWrapper(executablePath),
DisableFlagParsing: true,
} }
if doc.ShortDesc != "" { if doc.ShortDesc != "" {
parsedCmd.Short = doc.ShortDesc parsedCmd.Short = doc.ShortDesc
@ -140,7 +135,6 @@ func execWrapper(executablePath string) func(*cobra.Command, []string) error {
} }
func cli() int { func cli() int {
rootCommand.PersistentFlags().BoolFlagP("help", "h", false)
err := parseCommands(rootCmd, "core") err := parseCommands(rootCmd, "core")
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "failed to parse core commands: %s", err) fmt.Fprintf(os.Stderr, "failed to parse core commands: %s", err)