Skip to content

Commit

Permalink
commands/auth: use printer instead of fmt.Println (mattermost#500)
Browse files Browse the repository at this point in the history
  • Loading branch information
isacikgoz authored Apr 6, 2022
1 parent 3abf3e8 commit ce04482
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions commands/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func loginCmdF(cmd *cobra.Command, args []string) error {
}
}

fmt.Printf("\n credentials for %q: \"%s@%s\" stored\n\n", name, username, url)
printer.Print(fmt.Sprintf("\n credentials for %q: \"%s@%s\" stored\n", name, username, url))
return nil
}

Expand All @@ -265,7 +265,7 @@ func currentCmdF(cmd *cobra.Command, args []string) error {
return err
}

fmt.Printf("\n found credentials for %q: \"%s@%s\"\n\n", credentials.Name, credentials.Username, credentials.InstanceURL)
printer.Print(fmt.Sprintf("\n found credentials for %q: \"%s@%s\"\n", credentials.Name, credentials.Username, credentials.InstanceURL))
return nil
}

Expand All @@ -274,7 +274,7 @@ func setCmdF(cmd *cobra.Command, args []string) error {
return err
}

fmt.Printf("Credentials for server %q set as active\n", args[0])
printer.Print(fmt.Sprintf("Credentials for server %q set as active", args[0]))

return nil
}
Expand Down Expand Up @@ -307,17 +307,17 @@ func listCmdF(cmd *cobra.Command, args []string) error {
return serverNames[i] < serverNames[j]
})

fmt.Printf("\n | Active | %*s | %*s | %*s |\n", maxNameLen, "Name", maxUsernameLen, "Username", maxInstanceURLLen, "InstanceURL")
fmt.Printf(" |%s|%s|%s|%s|\n", strings.Repeat("-", 8), strings.Repeat("-", maxNameLen+2), strings.Repeat("-", maxUsernameLen+2), strings.Repeat("-", maxInstanceURLLen+2))
printer.Print(fmt.Sprintf("\n | Active | %*s | %*s | %*s |", maxNameLen, "Name", maxUsernameLen, "Username", maxInstanceURLLen, "InstanceURL"))
printer.Print(fmt.Sprintf(" |%s|%s|%s|%s|", strings.Repeat("-", 8), strings.Repeat("-", maxNameLen+2), strings.Repeat("-", maxUsernameLen+2), strings.Repeat("-", maxInstanceURLLen+2)))
for _, name := range serverNames {
c := (*credentialsList)[name]
if c.Active {
fmt.Printf(" | * | %*s | %*s | %*s |\n", maxNameLen, c.Name, maxUsernameLen, c.Username, maxInstanceURLLen, c.InstanceURL)
printer.Print(fmt.Sprintf(" | * | %*s | %*s | %*s |", maxNameLen, c.Name, maxUsernameLen, c.Username, maxInstanceURLLen, c.InstanceURL))
} else {
fmt.Printf(" | | %*s | %*s | %*s |\n", maxNameLen, c.Name, maxUsernameLen, c.Username, maxInstanceURLLen, c.InstanceURL)
printer.Print(fmt.Sprintf(" | | %*s | %*s | %*s |", maxNameLen, c.Name, maxUsernameLen, c.Username, maxInstanceURLLen, c.InstanceURL))
}
}
fmt.Println("")
printer.Print("")
return nil
}

Expand Down

0 comments on commit ce04482

Please sign in to comment.