From ef3d518d9abab07c9558bf2e70fa6c1fed78344a Mon Sep 17 00:00:00 2001 From: adnano Date: Mon, 10 May 2021 10:26:12 -0400 Subject: [PATCH] config: Make tasks an array --- config.go | 2 +- main.go | 17 ++--------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/config.go b/config.go index 7e4426a..f691776 100644 --- a/config.go +++ b/config.go @@ -14,7 +14,7 @@ type Config struct { Title string `toml:"title"` URLs []string `toml:"urls"` Feeds map[string]string `toml:"feeds"` - Tasks map[string]*Task `toml:"tasks"` + Tasks []*Task `toml:"tasks"` Permalinks map[string]string `toml:"permalinks"` templates *Templates } diff --git a/main.go b/main.go index e787c2f..4dbc565 100644 --- a/main.go +++ b/main.go @@ -42,12 +42,10 @@ func main() { func build() { var ( - task string config string ) flags := flag.NewFlagSet("kiln build", flag.ExitOnError) - flags.StringVar(&task, "t", "", "the task to run") flags.StringVar(&config, "c", "config.toml", "the configuration file to use") flags.Parse(os.Args[2:]) @@ -67,23 +65,12 @@ func build() { log.Fatal(err) } - if err := run(cfg, task); err != nil { + if err := run(cfg); err != nil { log.Fatal(err) } } -func run(cfg *Config, taskName string) error { - if taskName == "" { - return runAll(cfg) - } - task, ok := cfg.Tasks[taskName] - if !ok { - return fmt.Errorf("run task %q: no such task", taskName) - } - return runTask(cfg, task) -} - -func runAll(cfg *Config) error { +func run(cfg *Config) error { for _, task := range cfg.Tasks { err := runTask(cfg, task) if err != nil {