Documentation
¶
Overview ¶
Package console runs one-off commands inside the application context: a seed script, a data fix or a report that needs the same services as the app, without starting the HTTP server.
A command is any provider with a Name and a Run method:
type SeedCommand struct{ users *users.Service }
func (c *SeedCommand) Name() string { return "seed" }
func (c *SeedCommand) Run(ctx context.Context, args []string) error { ... }
and main hands its arguments over before it starts the server:
if len(os.Args) > 1 { // go run . seed
os.Exit(console.Main(ctx, AppModule(cfg, log), os.Args[1:], dygo.WithLogger(log)))
}
dygo generate command writes both.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrUnknown = errors.New("unknown command")
ErrUnknown is returned for a name no command has.
Functions ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.