Core

/app/cmd/root.go (1.4 KB)

 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package cmd

import (
"fmt"

"github.com/muesli/coral"

"{{{ .Package }}}/app/util"
)

func rootF(*coral.Command, []string) error {
// $PF_SECTION_START(rootAction)$
return startServer(_flags)
// $PF_SECTION_END(rootAction)$
}

func rootCmd() *coral.Command {
short := fmt.Sprintf("%s %s - %s", util.AppName, _buildInfo.Version, util.AppSummary)
ret := &coral.Command{Use: util.AppKey, Short: short, RunE: rootF}
ret.AddCommand(serverCmd(){{{ if .HasModule "marketing" }}}, siteCmd(), allCmd(){{{ end }}}{{{ if .HasModule "migration" }}}, migrateCmd(){{{ end }}}{{{ if .HasModule "upgrade" }}}, upgradeCmd(){{{ end }}}{{{ if .HasModule "wasmserver" }}}, wasmCmd(){{{ end }}})
// $PF_SECTION_START(cmds)$ - Add your commands here by calling ret.AddCommand
// $PF_SECTION_END(cmds)$
ret.AddCommand(versionCmd())

ret.PersistentFlags().StringVarP(&_flags.ConfigDir, "dir", "d", "", "directory for configuration, defaults to system config dir")
ret.PersistentFlags().BoolVarP(&_flags.Debug, "verbose", "v", false, "enables verbose logging and additional checks")
ret.PersistentFlags().StringVarP(&_flags.Address, "addr", "a", "127.0.0.1", "address to listen on, defaults to [127.0.0.1]")
ret.PersistentFlags().Uint16VarP(&_flags.Port, "port", "p", util.AppPort, fmt.Sprintf("port to listen on, defaults to [%d]", util.AppPort))

return ret
}