Add Tomorrow planning brief generation
This commit is contained in:
@@ -28,7 +28,7 @@ Options:
|
||||
--config PATH Load configuration from PATH instead of /usr/local/etc/weatherreporter/config.yml.
|
||||
--units VALUE Override weather API units.
|
||||
--tz NAME Override weather API timezone.
|
||||
--out PATH Write an extra Markdown report copy for generate daily.
|
||||
--out PATH Write an extra Markdown report copy for generate daily or tomorrow.
|
||||
`
|
||||
|
||||
type Runner struct {
|
||||
@@ -57,7 +57,7 @@ func (r Runner) Run(ctx context.Context, args []string, stdout io.Writer, stderr
|
||||
}
|
||||
return app.Generate(ctx, req)
|
||||
case "run":
|
||||
req, err := resolveRun(args[1:])
|
||||
req, err := r.resolveRun(args[1:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -82,6 +82,9 @@ type generateOptions struct {
|
||||
}
|
||||
|
||||
func (r Runner) resolveGenerate(args []string) (app.GenerateRequest, error) {
|
||||
if r.Clock == nil {
|
||||
r.Clock = timeutil.SystemClock{}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
return app.GenerateRequest{}, fmt.Errorf("generate requires a report name")
|
||||
}
|
||||
@@ -112,6 +115,7 @@ func (r Runner) resolveGenerate(args []string) (app.GenerateRequest, error) {
|
||||
Config: cfg,
|
||||
Report: report,
|
||||
OutputPath: opts.Output,
|
||||
Now: r.Clock.Now(),
|
||||
}
|
||||
|
||||
switch report {
|
||||
@@ -147,7 +151,10 @@ func (r Runner) resolveGenerate(args []string) (app.GenerateRequest, error) {
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func resolveRun(args []string) (app.BatchRequest, error) {
|
||||
func (r Runner) resolveRun(args []string) (app.BatchRequest, error) {
|
||||
if r.Clock == nil {
|
||||
r.Clock = timeutil.SystemClock{}
|
||||
}
|
||||
if len(args) == 0 {
|
||||
return app.BatchRequest{}, fmt.Errorf("run requires a batch name")
|
||||
}
|
||||
@@ -167,7 +174,11 @@ func resolveRun(args []string) (app.BatchRequest, error) {
|
||||
if err != nil {
|
||||
return app.BatchRequest{}, err
|
||||
}
|
||||
return app.BatchRequest{Config: cfg, Batch: batch}, nil
|
||||
return app.BatchRequest{Config: cfg, Batch: batch, Now: r.Clock.Now()}, nil
|
||||
}
|
||||
|
||||
func resolveRun(args []string) (app.BatchRequest, error) {
|
||||
return Runner{Clock: timeutil.SystemClock{}}.resolveRun(args)
|
||||
}
|
||||
|
||||
func parseGenerateFlags(report app.ReportKind, args []string) (generateOptions, error) {
|
||||
|
||||
Reference in New Issue
Block a user