package main import ( "fmt" "log" "os" "git.ulra.eu/adro/miniwol/config" "git.ulra.eu/adro/miniwol/web" "golang.org/x/crypto/bcrypt" ) func main() { if len(os.Args) < 2 { os.Args = append(os.Args, "") } switch os.Args[1] { case "setpass": passHash, err := bcrypt.GenerateFromPassword([]byte(os.Args[2]), bcrypt.DefaultCost) if err != nil { log.Fatal(err) } config.Config.PassHash = string(passHash) err = config.Save() if err != nil { log.Fatal(err) } fmt.Println("Successfully set password") case "web": fallthrough case "": log.Fatal(web.Run()) default: fmt.Println("Unknown subcommand", os.Args[1]) } }