diff --git a/config/config.go b/config/config.go index 5840c93..5a2254e 100644 --- a/config/config.go +++ b/config/config.go @@ -1,12 +1,14 @@ package config import ( + "fmt" "github.com/sqshq/sampler/console" "github.com/sqshq/sampler/data" . "github.com/sqshq/sampler/widgets" "gopkg.in/yaml.v2" "io/ioutil" "log" + "os" ) type Config struct { @@ -23,9 +25,14 @@ type RunChartConfig struct { Precision int `yaml:"decimal-places"` } -func Load(location string) *Config { +func Load(args []string) *Config { - cfg := readFile(location) + if len(args) < 2 { + fmt.Fprintf(os.Stderr, "Please specify config file location. See www.github.com/sqshq/sampler for the reference\n") + os.Exit(0) + } + + cfg := readFile(args[1]) cfg.validate() cfg.setDefaultValues() cfg.setDefaultColors() diff --git a/main.go b/main.go index d563670..c7ca66a 100644 --- a/main.go +++ b/main.go @@ -7,12 +7,13 @@ import ( "github.com/sqshq/sampler/event" "github.com/sqshq/sampler/widgets" ui "github.com/sqshq/termui" + "os" "time" ) func main() { - cfg := config.Load("/Users/sqshq/Go/src/github.com/sqshq/sampler/config.yml") + cfg := config.Load(os.Args) csl := console.Console{} csl.Init() defer csl.Close()