From 3dc7b2fbcaa0c94da854ba67a74dd438f0556e9c Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 14 Mar 2020 15:15:52 -0400 Subject: [PATCH] moved config file to a parameter --- configs/example-config.yaml | 8 +++++--- main.go | 12 +++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/configs/example-config.yaml b/configs/example-config.yaml index da167d3..e2ef769 100644 --- a/configs/example-config.yaml +++ b/configs/example-config.yaml @@ -1,12 +1,14 @@ IPFS: - Endpoint: ipfs.digscar.com:5001 + Endpoint: ec2-3-232-158-110.compute-1.amazonaws.com:5001 Eosio: Endpoint: https://kylin.eosusa.news PublishAccount: messengerbus PublishPrivateKey: 5KAP1zytghuvowgprSPLNasajibZcxf4KMgdgNbrNj98xhcGAUa Dfuse: + Protocol: GraphQL # WebSocket will use WSEndpoint; else it defaults to GraphQL WSEndpoint: wss://kylin.eos.dfuse.io/v1/stream Origin: github.com/eosio-enterprise/chappe - ApiKey: + ApiKey: <> + GraphQLEndpoint: kylin.eos.dfuse.io:443 KeyDirectory: channels/ -PublishInterval: 1s # Go Duration object +PublishInterval: 5s # Go Duration object \ No newline at end of file diff --git a/main.go b/main.go index 736f90f..6d61ef3 100644 --- a/main.go +++ b/main.go @@ -11,11 +11,6 @@ import ( func main() { - viper.SetConfigFile("configs/config.yaml") - if err := viper.ReadInConfig(); err != nil { - log.Fatalf("config file not found: %s", err) - } - cmdVersion := cmd.MakeVersion() cmdCreate := cmd.MakeCreate() cmdUpdate := cmd.MakeUpdate() @@ -30,6 +25,13 @@ func main() { }, } + var configFile string + rootCmd.Flags().StringVarP(&configFile, "config-file", "c", "configs/config.yaml", "Path/name of configuration file") + viper.SetConfigFile(configFile) //"configs/config.yaml") + if err := viper.ReadInConfig(); err != nil { + log.Fatalf("config file not found: %s", err) + } + rootCmd.AddCommand(cmdCreate) rootCmd.AddCommand(cmdVersion) rootCmd.AddCommand(cmdUpdate)