Exemplo n.º 1
0
Arquivo: main.go Projeto: gmelika/rack
func main() {
	app := stdcli.New()
	app.Version = Version
	app.Usage = "command-line application management"

	err := app.Run(os.Args)
	if err != nil {
		os.Exit(1)
	}
}
Exemplo n.º 2
0
Arquivo: main.go Projeto: convox/rack
func main() {
	app := stdcli.New()
	app.Version = Version
	app.Usage = "command-line application management"

	err := app.Run(os.Args)

	if err != nil {
		if err.Error() == "Token expired" {
			email, err := currentId()
			if err != nil {
				email = promptForUsername()
			} else {
				_, err := mail.ParseAddress(email)
				if err != nil {
					email = promptForUsername()
				}
			}

			pw := promptForPassword()
			host, _ := currentHost()
			cl := client.New(host, "", "")

			token, err := cl.RegenerateToken(email, pw)

			if err == nil {
				err = addLogin(host, token)
				if err != nil {
					stdcli.Error(err)
				}
				err = app.Run(os.Args)
				if err != nil {
					stdcli.Error(err)
					os.Exit(1)
				}
			} else {
				stdcli.Error(err)
				os.Exit(1)
			}
		}
		os.Exit(1)
	}
}