diff options
author | 2022-11-15 16:53:19 +0100 | |
---|---|---|
committer | 2022-11-15 16:53:19 +0100 | |
commit | 1f256e288b876fcd58093068150e0542acc82b32 (patch) | |
tree | 0af518fa106a81d5b987f16a8dbd71fd2ad09a53 /internal/config/flags.go | |
parent | [bugfix] Fix unicode-unaware word boundary check in hashtags (#1049) (diff) | |
download | gotosocial-1f256e288b876fcd58093068150e0542acc82b32.tar.xz |
[chore] refactor test/cliparsing.sh into a go test below internal/config (#1036)
Also adds AddGlobalFlags and AddServerFlags as methods on ConfigState,
very useful for testing.
Diffstat (limited to 'internal/config/flags.go')
-rw-r--r-- | internal/config/flags.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/internal/config/flags.go b/internal/config/flags.go index bb3f67732..ddc3c60de 100644 --- a/internal/config/flags.go +++ b/internal/config/flags.go @@ -26,7 +26,12 @@ import ( // AddGlobalFlags will attach global configuration flags to given cobra command, loading defaults from global config. func AddGlobalFlags(cmd *cobra.Command) { - Config(func(cfg *Configuration) { + global.AddGlobalFlags(cmd) +} + +// AddGlobalFlags will attach global configuration flags to given cobra command, loading defaults from State. +func (s *ConfigState) AddGlobalFlags(cmd *cobra.Command) { + s.Config(func(cfg *Configuration) { // General cmd.PersistentFlags().String(ApplicationNameFlag(), cfg.ApplicationName, fieldtag("ApplicationName", "usage")) cmd.PersistentFlags().String(LandingPageUserFlag(), cfg.LandingPageUser, fieldtag("LandingPageUser", "usage")) @@ -51,7 +56,12 @@ func AddGlobalFlags(cmd *cobra.Command) { // AddServerFlags will attach server configuration flags to given cobra command, loading defaults from global config. func AddServerFlags(cmd *cobra.Command) { - Config(func(cfg *Configuration) { + global.AddServerFlags(cmd) +} + +// AddServerFlags will attach server configuration flags to given cobra command, loading defaults from State. +func (s *ConfigState) AddServerFlags(cmd *cobra.Command) { + s.Config(func(cfg *Configuration) { // Router cmd.PersistentFlags().String(BindAddressFlag(), cfg.BindAddress, fieldtag("BindAddress", "usage")) cmd.PersistentFlags().Int(PortFlag(), cfg.Port, fieldtag("Port", "usage")) |