package main import ( "errors" "fmt" "isle/bootstrap" ) var subCmdNetworkJoin = subCmd{ name: "join", descr: "Joins this host to an existing network", do: func(subCmdCtx subCmdCtx) error { var ( ctx = subCmdCtx.ctx flags = subCmdCtx.flagSet(false) ) bootstrapPath := flags.StringP( "bootstrap-path", "b", "", "Path to a bootstrap.json file.", ) if err := flags.Parse(subCmdCtx.args); err != nil { return fmt.Errorf("parsing flags: %w", err) } if *bootstrapPath == "" { return errors.New("--bootstrap-path is required") } newBootstrap, err := bootstrap.FromFile(*bootstrapPath) if err != nil { return fmt.Errorf( "loading bootstrap from %q: %w", *bootstrapPath, err, ) } return subCmdCtx.daemonRCPClient.Call( ctx, nil, "JoinNetwork", newBootstrap, ) }, } var subCmdNetwork = subCmd{ name: "network", descr: "Sub-commands related to network membership", do: func(subCmdCtx subCmdCtx) error { return subCmdCtx.doSubCmd( subCmdNetworkJoin, ) }, }