mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[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.
This commit is contained in:
committed by
GitHub
parent
52109776f6
commit
1f256e288b
@@ -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"))
|
||||
|
Reference in New Issue
Block a user