mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-10-29 17:22:24 -05: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:
parent
52109776f6
commit
1f256e288b
9 changed files with 222 additions and 126 deletions
|
|
@ -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"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue