mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-25 07:43:10 -06:00
Take first argument if flags package doesn't find any args
This commit is contained in:
parent
705339d098
commit
26c237a36c
|
|
@ -29,7 +29,13 @@ type entrypoint func(base *setup.BaseDendrite, cfg *config.Dendrite)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cfg := setup.ParseFlags(true)
|
cfg := setup.ParseFlags(true)
|
||||||
component := flag.Arg(0)
|
|
||||||
|
component := ""
|
||||||
|
if flag.NFlag() > 0 {
|
||||||
|
component = flag.Arg(0) // ./dendrite-polylith-multi --config=... clientapi
|
||||||
|
} else if len(os.Args) > 1 {
|
||||||
|
component = os.Args[1] // ./dendrite-polylith-multi clientapi
|
||||||
|
}
|
||||||
|
|
||||||
components := map[string]entrypoint{
|
components := map[string]entrypoint{
|
||||||
"appservice": personalities.Appservice,
|
"appservice": personalities.Appservice,
|
||||||
|
|
@ -47,13 +53,19 @@ func main() {
|
||||||
|
|
||||||
start, ok := components[component]
|
start, ok := components[component]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
if component == "" {
|
||||||
|
logrus.Errorf("No component specified")
|
||||||
|
logrus.Info("The first argument on the command line must be the name of the component to run")
|
||||||
|
} else {
|
||||||
|
logrus.Errorf("Unknown component %q specified", component)
|
||||||
|
}
|
||||||
|
|
||||||
var list []string
|
var list []string
|
||||||
for c := range components {
|
for c := range components {
|
||||||
list = append(list, c)
|
list = append(list, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Errorf("Unknown component %q specified", component)
|
|
||||||
logrus.Infof("Valid components: %s", strings.Join(list, ", "))
|
logrus.Infof("Valid components: %s", strings.Join(list, ", "))
|
||||||
|
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue