add admin bucket back
parent
66d91bd1ba
commit
8115522703
10
main.go
10
main.go
|
@ -13,13 +13,18 @@ import (
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
const binroot = "/town/launcher"
|
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",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var adminCmd = &cobra.Command{
|
||||||
|
Use: "admin",
|
||||||
|
Short: "Run administrative commands",
|
||||||
|
}
|
||||||
|
|
||||||
func isAdmin() (bool, error) {
|
func isAdmin() (bool, error) {
|
||||||
u, err := user.Current()
|
u, err := user.Current()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -148,7 +153,8 @@ func cli() int {
|
||||||
}
|
}
|
||||||
|
|
||||||
if admin {
|
if admin {
|
||||||
err = parseCommands(rootCmd, "admin")
|
rootCmd.AddCommand(adminCmd)
|
||||||
|
err = parseCommands(adminCmd, "admin")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "failed to parse admin commands: %s", err)
|
fmt.Fprintf(os.Stderr, "failed to parse admin commands: %s", err)
|
||||||
return 1
|
return 1
|
||||||
|
|
Reference in New Issue