コード例 #1
0
ファイル: accounts.go プロジェクト: dubsquared/kumoru-cli
//Show displays the details of an Account.
func Show(cmd *cli.Cmd) {
	email := cmd.String(cli.StringArg{
		Name:      "EMAIL",
		Desc:      "email address",
		HideValue: true,
	})

	cmd.Action = func() {
		a := authorization.Account{
			Email: *email,
		}

		account, resp, errs := a.ShowAcct()

		if len(errs) > 0 {
			log.Fatalf("Could not retrieve account: %s", errs[0])
		}

		if resp.StatusCode != 200 {
			log.Fatalf("Could not retrieve account: %s", resp.Status)
		}

		printAccountDetail(account)
	}
}
コード例 #2
0
ファイル: accounts.go プロジェクト: dubsquared/kumoru-cli
//ResetPassword requests the password reset operation to start.
func ResetPassword(cmd *cli.Cmd) {
	email := cmd.String(cli.StringArg{
		Name:      "EMAIL",
		Desc:      "email address",
		HideValue: true,
	})

	cmd.Action = func() {
		a := authorization.Account{
			Email: *email,
		}

		account, resp, errs := a.ResetPassword()

		if len(errs) > 0 {
			log.Fatalf("Could not retrieve account: %s", errs[0])
		}

		if resp.StatusCode != 204 {
			log.Fatalf("Could not reset account password: %s", resp.Status)
		}

		fmt.Println("Password reset instructions sent to:", account.Email)
	}
}
コード例 #3
0
ファイル: accounts.go プロジェクト: dubsquared/kumoru-cli
//Create an Account.
func Create(cmd *cli.Cmd) {
	email := cmd.String(cli.StringArg{
		Name:      "EMAIL",
		Desc:      "email address",
		HideValue: true,
	})

	fName := cmd.String(cli.StringOpt{
		Name:      "f first-name",
		Desc:      "Given Name",
		HideValue: true,
	})

	lName := cmd.String(cli.StringOpt{
		Name:      "l last-name",
		Desc:      "Last Name",
		HideValue: true,
	})

	password := cmd.String(cli.StringOpt{
		Name:      "p password",
		Desc:      "Password",
		HideValue: true,
	})

	cmd.Action = func() {

		if *password == "" {
			*password = passwordPrompt()
			fmt.Println("\n")
		}

		l := authorization.Account{
			Email:     *email,
			GivenName: *fName,
			Surname:   *lName,
		}

		account, resp, errs := l.CreateAcct(*password)

		if len(errs) > 0 {
			log.Fatalf("Could not create account: %s", errs[0])
		}

		if resp.StatusCode != 201 {
			log.Fatalf("Could not create account: %s", resp.Status)
		}

		printAccountDetail(account)
	}
}