gosuki/cmd/mod_flags.go

50 lines
1.5 KiB
Go
Raw Normal View History

2023-09-16 15:25:25 +00:00
//
// Copyright ⓒ 2023 Chakib Ben Ziane <contact@blob42.xyz> and [`GoSuki` contributors]
// (https://github.com/blob42/gosuki/graphs/contributors).
//
// All rights reserved.
//
// SPDX-License-Identifier: AGPL-3.0-or-later
//
// This file is part of GoSuki.
//
// GoSuki is free software: you can redistribute it and/or modify it under the terms of
// the GNU Affero General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// GoSuki is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License along with
// gosuki. If not, see <http://www.gnu.org/licenses/>.
package cmd
import (
"github.com/urfave/cli/v2"
)
var modFlags = map[string][]cli.Flag{}
2023-09-05 17:45:21 +00:00
// RegGlobalModFlag registers global flags to pass on to the browser module
func RegGlobalModFlag(modID string, flag cli.Flag) {
if flag == nil {
log.Panic("registering nil flag")
}
2023-09-05 17:45:21 +00:00
log.Debugf("<%s> registering global flag: %s",
modID,
flag.Names())
if _, ok := modFlags[modID]; !ok {
modFlags[modID] = []cli.Flag{flag}
} else {
2023-09-05 17:45:21 +00:00
modFlags[modID] = append(modFlags[modID], flag)
}
}
2023-09-05 17:45:21 +00:00
// GlobalFlags returns the registered global flags for a given registered module
func GlobalFlags(modID string) []cli.Flag {
return modFlags[modID]
}