Skip to content

Commit

Permalink
Merge pull request #79 from hyperledger/conf-rootcmd
Browse files Browse the repository at this point in the history
Only require the -f parameter on the root command
  • Loading branch information
peterbroadhurst authored Apr 27, 2023
2 parents 9512b8a + 21cbe97 commit 5c2749a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions cmd/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2022 Kaleido, Inc.
// Copyright © 2023 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -30,7 +30,7 @@ func configCommand() *cobra.Command {
Short: "Prints the config info as markdown",
Long: "",
RunE: func(cmd *cobra.Command, args []string) error {
initConfig()
InitConfig()
b, err := config.GenerateConfigMarkdown(context.Background(), "", config.GetKnownKeys())
fmt.Println(string(b))
return err
Expand Down
4 changes: 2 additions & 2 deletions cmd/config_docs_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2022 Kaleido, Inc.
// Copyright © 2023 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -32,7 +32,7 @@ import (

func TestConfigDocsUpToDate(t *testing.T) {
// Initialize config of all plugins
initConfig()
InitConfig()
generatedConfig, err := config.GenerateConfigMarkdown(context.Background(), "", config.GetKnownKeys())
assert.NoError(t, err)
configOnDisk, err := os.ReadFile(filepath.Join("..", "config.md"))
Expand Down
5 changes: 2 additions & 3 deletions cmd/evmconnect.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var cfgFile string
var connectorConfig config.Section

func init() {
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "f", "", "config file")
rootCmd.Flags().StringVarP(&cfgFile, "config", "f", "", "config file")
rootCmd.AddCommand(versionCommand())
rootCmd.AddCommand(configCommand())
rootCmd.AddCommand(fftmcmd.ClientCommand())
Expand All @@ -61,7 +61,7 @@ func Execute() error {
return rootCmd.Execute()
}

func initConfig() {
func InitConfig() {
fftm.InitConfig()
connectorConfig = config.RootSection("connector")
ethereum.InitConfig(connectorConfig)
Expand All @@ -70,7 +70,6 @@ func initConfig() {

func run() error {

initConfig()
err := config.ReadConfig("evmconnect", cfgFile)

// Setup logging after reading config (even if failed), to output header correctly
Expand Down
3 changes: 2 additions & 1 deletion evmconnect/main.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2022 Kaleido, Inc.
// Copyright © 2023 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand All @@ -24,6 +24,7 @@ import (
)

func main() {
cmd.InitConfig()
if err := cmd.Execute(); err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err)
os.Exit(1)
Expand Down

0 comments on commit 5c2749a

Please sign in to comment.