diff --git a/app.go b/app.go index 7686572..e88af2a 100644 --- a/app.go +++ b/app.go @@ -87,6 +87,51 @@ func NewApp(configPath string, users UserManager, runner CommandRunner, lookPath } func (a *App) Run() error { + for { + choice, err := a.chooseStartupWorkflow() + if err != nil { + return err + } + + switch choice { + case "server": + return a.runServerWorkflow() + case "client": + return a.setupClientMount() + case "quit": + return nil + } + } +} + +func (a *App) chooseStartupWorkflow() (string, error) { + a.println("") + a.println("Samba setup assistant") + a.println("=====================") + a.println("[s] set up or edit shares on this computer") + a.println("[c] connect this computer to a share on another server") + a.println("[q] quit") + a.flush() + + choice, err := a.prompt("What would you like to do") + if err != nil { + return "", err + } + + switch strings.ToLower(choice) { + case "s", "server": + return "server", nil + case "c", "client": + return "client", nil + case "q", "quit": + return "quit", nil + default: + a.println("Unknown choice.") + return a.chooseStartupWorkflow() + } +} + +func (a *App) runServerWorkflow() error { doc, err := ParseConfigFile(a.configPath) if err != nil { if os.IsNotExist(err) { diff --git a/samba-configer b/samba-configer index df4c50c..4ab23c4 100755 Binary files a/samba-configer and b/samba-configer differ