-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
590 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package utils | ||
|
||
import ( | ||
"go/types" | ||
|
||
"github.com/sirupsen/logrus" | ||
"github.com/stellar/go/network" | ||
"github.com/stellar/go/support/config" | ||
) | ||
|
||
func DatabaseURLOption(configKey *string) *config.ConfigOption { | ||
return &config.ConfigOption{ | ||
Name: "database-url", | ||
Usage: "Database connection URL.", | ||
OptType: types.String, | ||
ConfigKey: configKey, | ||
FlagDefault: "postgres://postgres@localhost:5432/wallet-backend?sslmode=disable", | ||
Required: true, | ||
} | ||
} | ||
|
||
func LogLevelOption(configKey *logrus.Level) *config.ConfigOption { | ||
return &config.ConfigOption{ | ||
Name: "log-level", | ||
Usage: `The log level used in this project. Options: "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL", or "PANIC".`, | ||
OptType: types.String, | ||
FlagDefault: "TRACE", | ||
ConfigKey: configKey, | ||
CustomSetValue: SetConfigOptionLogLevel, | ||
Required: false, | ||
} | ||
} | ||
|
||
func NetworkPassphraseOption(configKey *string) *config.ConfigOption { | ||
return &config.ConfigOption{ | ||
Name: "network-passphrase", | ||
Usage: "Stellar Network Passphrase to connect.", | ||
OptType: types.String, | ||
ConfigKey: configKey, | ||
FlagDefault: network.TestNetworkPassphrase, | ||
Required: true, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package utils | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/stellar/go/support/config" | ||
) | ||
|
||
func DefaultPersistentPreRunE(cfgOpts config.ConfigOptions) func(_ *cobra.Command, _ []string) error { | ||
return func(_ *cobra.Command, _ []string) error { | ||
if err := cfgOpts.RequireE(); err != nil { | ||
return fmt.Errorf("requiring values of config options: %w", err) | ||
} | ||
if err := cfgOpts.SetValues(); err != nil { | ||
return fmt.Errorf("setting values of config options: %w", err) | ||
} | ||
return nil | ||
} | ||
} |
Oops, something went wrong.