MCPcopy Index your code
hub / github.com/coder/coder / promptFirstUsername

Function promptFirstUsername

cli/login.go:42–59  ·  view source on GitHub ↗
(inv *serpent.Invocation)

Source from the content-addressed store, hash-verified

40}
41
42func promptFirstUsername(inv *serpent.Invocation) (string, error) {
43 currentUser, err := user.Current()
44 if err != nil {
45 return "", xerrors.Errorf("get current user: %w", err)
46 }
47 username, err := cliui.Prompt(inv, cliui.PromptOptions{
48 Text: "What " + pretty.Sprint(cliui.DefaultStyles.Field, "username") + " would you like?",
49 Default: currentUser.Username,
50 })
51 if errors.Is(err, cliui.ErrCanceled) {
52 return "", nil
53 }
54 if err != nil {
55 return "", err
56 }
57
58 return username, nil
59}
60
61func promptFirstName(inv *serpent.Invocation) (string, error) {
62 name, err := cliui.Prompt(inv, cliui.PromptOptions{

Callers 1

loginMethod · 0.85

Calls 3

PromptFunction · 0.92
ErrorfMethod · 0.45
IsMethod · 0.45

Tested by

no test coverage detected