mirror of
https://codeberg.org/june64/mrvc.git
synced 2026-01-10 16:06:33 +01:00
introduce option for recursively checking all child rooms as well
This commit is contained in:
parent
f805786ae0
commit
919127e255
4 changed files with 72 additions and 2 deletions
|
|
@ -23,6 +23,7 @@ type configOptions struct {
|
|||
userID configOption[string]
|
||||
token configOption[string]
|
||||
rooms configOption[rooms]
|
||||
recursive configOption[bool]
|
||||
printHomeserverMemberCount configOption[bool]
|
||||
homeserverVersionInfoTimeout configOption[time.Duration]
|
||||
}
|
||||
|
|
@ -31,6 +32,7 @@ type Config struct {
|
|||
UserID string
|
||||
Token string
|
||||
Rooms rooms
|
||||
Recursive bool
|
||||
PrintHomeserverMemberCount bool
|
||||
HomeserverVersionInfoTimeout time.Duration
|
||||
}
|
||||
|
|
@ -39,6 +41,7 @@ var configOpts = configOptions{
|
|||
userID: configOption[string]{"user-id", "", "The Matrix user ID to use.", "MRVC_USER_ID"},
|
||||
token: configOption[string]{"token", "", "The Matrix access token to use.", "MRVC_TOKEN"},
|
||||
rooms: configOption[rooms]{"room", []string{}, "The Matrix room to check. The flag can be set multiple times to check multiple rooms.", "MRVC_ROOM"},
|
||||
recursive: configOption[bool]{"recursive", false, "Recursively check the child rooms for the given rooms (spaces) as well.", "MRVC_RECURSIVE"},
|
||||
printHomeserverMemberCount: configOption[bool]{"print-homeserver-member-count", false, "Print the member count for each homeserver.", "MRVC_PRINT_HOMESERVER_MEMBER_COUNT"},
|
||||
homeserverVersionInfoTimeout: configOption[time.Duration]{"homeserver-version-info-timeout", time.Second * 5, "Timeout for getting the homeservers version information per homeserver.", "MRVC_HOMESERVER_VERSION_INFO_TIMEOUT"},
|
||||
}
|
||||
|
|
@ -85,6 +88,7 @@ func (configOpt configOption[T]) getConfigValueWithError(configFlag *T, visitedF
|
|||
|
||||
var userIdFlag = flag.String(configOpts.userID.getFlagArgs())
|
||||
var tokenFlag = flag.String(configOpts.token.getFlagArgs())
|
||||
var recursiveFlag = flag.Bool(configOpts.recursive.getFlagArgs())
|
||||
var printHomeserverMemberCountFlag = flag.Bool(configOpts.printHomeserverMemberCount.getFlagArgs())
|
||||
var homeserverVersionInfoTimeoutFlag = flag.Duration(configOpts.homeserverVersionInfoTimeout.getFlagArgs())
|
||||
|
||||
|
|
@ -118,6 +122,14 @@ func Get() Config {
|
|||
if err != nil {
|
||||
log.Fatal("A Matrix room must be provided.")
|
||||
}
|
||||
config.Recursive = configOpts.recursive.getConfigValueWithDefault(recursiveFlag, visitedFlags, func(envVar string) bool {
|
||||
parsedEnvVar, err := strconv.ParseBool(envVar)
|
||||
if err != nil {
|
||||
log.Printf("Error parsing %s:\n", configOpts.recursive.envVarName)
|
||||
log.Fatal(err)
|
||||
}
|
||||
return parsedEnvVar
|
||||
})
|
||||
config.PrintHomeserverMemberCount = configOpts.printHomeserverMemberCount.getConfigValueWithDefault(printHomeserverMemberCountFlag, visitedFlags, func(envVar string) bool {
|
||||
parsedEnvVar, err := strconv.ParseBool(envVar)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue