package config import ( "flag" "log" "github.com/BurntSushi/toml" ) type config struct { Test int TestStart int Debug int Progress bool ConfigPath string Scale string VideoBitrate int AudioBitrate int Speed string CleanFilename bool CRF int FPS int Tune string Input string Output string OutDir string } var Settings config func parseFlags(c *config) { flag.IntVar(&c.Test, "test", 0, "Make a test video seconds long.") flag.IntVar(&c.TestStart, "test-start", 60, "When to start the test clip.") flag.IntVar(&c.Debug, "debug", 0, "1=print the ffmpeg command, 2=and its stderr output") flag.BoolVar(&c.Progress, "progress", false, "Show percent progress. Not accurate (thanks ffmpeg)") flag.StringVar(&c.ConfigPath, "config", "config.toml", "config.toml to load") flag.Parse() } func Load() { parseFlags(&Settings) metadata, err := toml.DecodeFile(Settings.ConfigPath, &Settings) if err != nil { log.Fatalf("error loading config.toml: %v", err) } bad_keys := metadata.Undecoded() if len(bad_keys) > 0 { log.Fatalf("unknown configuration keys: %v", bad_keys); } }