- Global options -v/-vv/-vvv, -q, --ansi/--no-ansi, -n and --env on every command; PeekGlobals reads them before config loads, OnGlobals hooks re-apply them after parsing (diary.ApplyGlobals in the generated main) - Bare binary, --help and list print the Artisan list with the version header from BuildVersion and namespace blocks - Execute runs the root through fang (no version, man page or completions) and returns 0, 1 or 2; Fail renders errors before the root exists - NewRoot rejects duplicate command names (ErrDuplicateCommand) and flags that reuse a global option (ErrReservedFlag) - Generated main and summer use PeekGlobals, compass.Open with --env, diary.FromGlobals and bonfire.Execute; docs checker knows the globals
60 lines
2.0 KiB
Go
60 lines
2.0 KiB
Go
// Code generated by summer build. DO NOT EDIT.
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"os"
|
|
|
|
"git.golem15.com/golem15/summercms/modules/backpack"
|
|
"git.golem15.com/golem15/summercms/modules/bonfire"
|
|
"git.golem15.com/golem15/summercms/modules/cabana"
|
|
"git.golem15.com/golem15/summercms/modules/compass"
|
|
"git.golem15.com/golem15/summercms/modules/conga"
|
|
"git.golem15.com/golem15/summercms/modules/diary"
|
|
"git.golem15.com/golem15/summercms/modules/lagoon"
|
|
"git.golem15.com/golem15/summercms/modules/pact"
|
|
"git.golem15.com/golem15/summercms/modules/party"
|
|
"git.golem15.com/golem15/summercms/modules/surf"
|
|
)
|
|
|
|
func main() {
|
|
os.Exit(run(os.Args[1:], os.Stdout))
|
|
}
|
|
|
|
func run(args []string, out io.Writer) int {
|
|
g := bonfire.PeekGlobals(args)
|
|
diary.Bootstrap(os.Stderr, diary.FromGlobals(g))
|
|
cfg, err := compass.Open(compass.Options{Dir: "config", Env: g.Env})
|
|
if err != nil {
|
|
return bonfire.Fail(os.Stderr, "hello", err, g)
|
|
}
|
|
if err := diary.Setup(cfg, diary.FromGlobals(g)); err != nil {
|
|
return bonfire.Fail(os.Stderr, "hello", err, g)
|
|
}
|
|
app := backpack.New(cfg)
|
|
plugins, err := party.Activate(app, PluginIDs)
|
|
if err != nil {
|
|
return bonfire.Fail(os.Stderr, "hello", err, g)
|
|
}
|
|
commands := lagoon.RuntimeCommands(app, plugins)
|
|
commands = append(commands, conga.RuntimeCommands(app, plugins)...)
|
|
commands = append(commands, surf.ServeCommand(app, plugins))
|
|
commands = append(commands, surf.RouteListCommand(app, plugins))
|
|
commands = append(commands, cabana.RuntimeCommands(app)...)
|
|
for _, plugin := range plugins {
|
|
if hasCommands, ok := plugin.(pact.HasCommands); ok {
|
|
commands = append(commands, hasCommands.Commands()...)
|
|
}
|
|
}
|
|
if err := app.Publish(bonfire.NewCatalog(commands)); err != nil {
|
|
return bonfire.Fail(os.Stderr, "hello", err, g)
|
|
}
|
|
root, err := bonfire.NewRoot("hello", commands, out, bonfire.WithVersion(bonfire.BuildVersion()), bonfire.OnGlobals(diary.ApplyGlobals))
|
|
if err != nil {
|
|
return bonfire.Fail(os.Stderr, "hello", err, g)
|
|
}
|
|
return bonfire.Execute(context.Background(), root, args)
|
|
}
|