mirror of
https://github.com/0x1d/rcond.git
synced 2026-03-23 01:11:06 +01:00
feat: basic configuration UI
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/0x1d/rcond/pkg/config"
|
||||
"github.com/0x1d/rcond/pkg/rcond"
|
||||
"github.com/0x1d/rcond/pkg/ui"
|
||||
)
|
||||
|
||||
func usage() {
|
||||
@@ -24,9 +25,24 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
rcond.NewNode(appConfig).Up()
|
||||
switch appConfig.RunMode {
|
||||
case config.RunModeNode:
|
||||
fmt.Println("running node")
|
||||
// Validate required fields
|
||||
if err := validateRequiredFields(map[string]*string{
|
||||
"addr": &appConfig.Rcond.Addr,
|
||||
"token": &appConfig.Rcond.ApiToken,
|
||||
}); err != nil {
|
||||
usage()
|
||||
fmt.Printf("\nFailed to validate required fields: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
rcond.NewNode(appConfig).Up()
|
||||
select {}
|
||||
case config.RunModeUI:
|
||||
ui.NewUI(appConfig)
|
||||
}
|
||||
|
||||
select {}
|
||||
}
|
||||
|
||||
func loadConfig() (*config.Config, error) {
|
||||
@@ -36,6 +52,8 @@ func loadConfig() (*config.Config, error) {
|
||||
|
||||
flag.StringVar(&configPath, "config", configPath, "Path to the configuration file")
|
||||
flag.BoolVar(&help, "help", false, "Show help")
|
||||
// check for runmode
|
||||
runMode := flag.String("runmode", "node", "Run mode: node or ui")
|
||||
flag.Parse()
|
||||
|
||||
if help {
|
||||
@@ -51,15 +69,7 @@ func loadConfig() (*config.Config, error) {
|
||||
}
|
||||
appConfig = configFile
|
||||
}
|
||||
|
||||
// Validate required fields
|
||||
if err := validateRequiredFields(map[string]*string{
|
||||
"addr": &appConfig.Rcond.Addr,
|
||||
"token": &appConfig.Rcond.ApiToken,
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
appConfig.RunMode = config.RunMode(*runMode)
|
||||
return appConfig, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user