Skip to content

Commit

Permalink
Issue #642: Use more standard naming for Out/OutW/OutF
Browse files Browse the repository at this point in the history
They are similar to fmt.Println/fmt.Fprint/fmt.Printf so they are
renamed to Outln/Fout/Outf.

This fixes #642
  • Loading branch information
cfergeau authored and praveenkumar committed Sep 26, 2019
1 parent 75b417e commit 93131d1
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions cmd/crc/cmd/config/get.go
Expand Up @@ -19,7 +19,7 @@ var configGetCmd = &cobra.Command{
to the options that you set when you run the 'crc start' command.`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) < 1 {
output.Out("Please provide a configuration property to retrieve")
output.Outln("Please provide a configuration property to retrieve")
os.Exit(1)
}
runConfigGet(args[0])
Expand All @@ -31,5 +31,5 @@ func runConfigGet(key string) {
if err != nil {
errors.ExitWithMessage(1, err.Error())
}
output.Out(key, ":", v)
output.Outln(key, ":", v)
}
2 changes: 1 addition & 1 deletion cmd/crc/cmd/config/set.go
Expand Up @@ -36,6 +36,6 @@ func runConfigSet(key string, value interface{}) {
}

if setMessage != "" {
output.Out(setMessage)
output.Outln(setMessage)
}
}
2 changes: 1 addition & 1 deletion cmd/crc/cmd/config/unset.go
Expand Up @@ -35,6 +35,6 @@ func runConfigUnset(key string) {
}

if unsetMsg != "" {
output.Out(unsetMsg)
output.Outln(unsetMsg)
}
}
4 changes: 2 additions & 2 deletions cmd/crc/cmd/console.go
Expand Up @@ -52,9 +52,9 @@ func runConsole(arguments []string) {
}

if consoleURLMode {
output.Out(result.URL)
output.Outln(result.URL)
return
}
output.Out("Opening the OpenShift Web console in the default browser...")
output.Outln("Opening the OpenShift Web console in the default browser...")
_ = browser.OpenURL(result.URL)
}
2 changes: 1 addition & 1 deletion cmd/crc/cmd/delete.go
Expand Up @@ -42,7 +42,7 @@ func runDelete(arguments []string) {
if err != nil {
errors.Exit(1)
}
output.Out("CodeReady Containers instance deleted")
output.Outln("CodeReady Containers instance deleted")
}

func deleteCache() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/crc/cmd/ip.go
Expand Up @@ -32,5 +32,5 @@ func runIP(arguments []string) {
if err != nil {
errors.Exit(1)
}
output.Out(result.IP)
output.Outln(result.IP)
}
2 changes: 1 addition & 1 deletion cmd/crc/cmd/root.go
Expand Up @@ -60,7 +60,7 @@ func runPostrun() {
}

func runRoot() {
output.Out("No command given")
output.Outln("No command given")
}

func Execute() {
Expand Down
4 changes: 2 additions & 2 deletions cmd/crc/cmd/setup.go
Expand Up @@ -34,9 +34,9 @@ func runSetup(arguments []string) {
}
preflight.SetupHost(vmDriver)
if constants.BundleEmbedded() {
output.Out("Setup is complete, you can now run 'crc start' to start a CodeReady Containers instance")
output.Outln("Setup is complete, you can now run 'crc start' to start a CodeReady Containers instance")
} else {
output.Out("Setup is complete, you can now run 'crc start -b $bundlename' to start a CodeReady Containers instance")
output.Outln("Setup is complete, you can now run 'crc start -b $bundlename' to start a CodeReady Containers instance")
}
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/crc/cmd/start.go
Expand Up @@ -62,7 +62,7 @@ func runStart(arguments []string) {
errors.Exit(1)
}
if commandResult.Status == "Running" {
output.Out("CodeReady Containers instance is running")
output.Outln("CodeReady Containers instance is running")
} else {
logging.Warnf("Unexpected status: %s", commandResult.Status)
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/crc/cmd/stop.go
Expand Up @@ -35,7 +35,7 @@ func runStop(arguments []string) {
Name: constants.DefaultName,
}

output.Out("Stopping CodeReady Containers instance... this may take a few minutes")
output.Outln("Stopping CodeReady Containers instance... this may take a few minutes")
commandResult, err := machine.Stop(stopConfig)
if err != nil {
// Here we are checking the VM state and if it is still running then
Expand All @@ -53,7 +53,7 @@ func runStop(arguments []string) {
errors.Exit(1)
}
if commandResult.Success {
output.Out("CodeReady Containers instance stopped")
output.Outln("CodeReady Containers instance stopped")
} else {
/* If we did not get an error, the status should be true */
logging.Warnf("Unexpected status %v", commandResult.Success)
Expand All @@ -65,5 +65,5 @@ func killVM(killConfig machine.PowerOffConfig) {
if err != nil {
errors.Exit(1)
}
output.Out("CodeReady Containers instance forcibly stopped")
output.Outln("CodeReady Containers instance forcibly stopped")
}
4 changes: 2 additions & 2 deletions pkg/crc/errors/atexit.go
Expand Up @@ -44,9 +44,9 @@ func Exit(code int) {
// If the exit code is 0, the message is prints to stdout, otherwise to stderr.
func ExitWithMessage(code int, text string, args ...interface{}) {
if code == 0 {
_, _ = output.OutW(os.Stdout, fmt.Sprintf(text, args...))
_, _ = output.Fout(os.Stdout, fmt.Sprintf(text, args...))
} else {
_, _ = output.OutW(os.Stderr, fmt.Sprintf(text, args...))
_, _ = output.Fout(os.Stderr, fmt.Sprintf(text, args...))
}
Exit(code)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/crc/input/input.go
Expand Up @@ -13,7 +13,7 @@ func PromptUserForYesOrNo(message string, force bool) bool {
return true
}
var response string
output.OutF(message + "? [y/N]: ")
output.Outf(message + "? [y/N]: ")
fmt.Scanf("%s", &response)

return strings.ToLower(response) == "y"
Expand Down
6 changes: 3 additions & 3 deletions pkg/crc/output/output.go
Expand Up @@ -5,14 +5,14 @@ import (
"io"
)

func Out(args ...interface{}) {
func Outln(args ...interface{}) {
fmt.Println(args...)
}

func OutF(s string, args ...interface{}) {
func Outf(s string, args ...interface{}) {
fmt.Printf(s, args...)
}

func OutW(w io.Writer, args ...interface{}) (n int, err error) {
func Fout(w io.Writer, args ...interface{}) (n int, err error) {
return fmt.Fprintln(w, args...)
}
2 changes: 1 addition & 1 deletion pkg/crc/services/dns/dns_windows.go
Expand Up @@ -18,7 +18,7 @@ import (
func runPostStartForOS(serviceConfig services.ServicePostStartConfig, result *services.ServicePostStartResult) (services.ServicePostStartResult, error) {
// bailout for Virtualbox
if serviceConfig.DriverName == "virtualbox" {
output.Out("Please follow instructions in the documentation about setting hostnames for Virtualbox.")
output.Outln("Please follow instructions in the documentation about setting hostnames for Virtualbox.")
result.Success = true
return *result, nil
}
Expand Down

0 comments on commit 93131d1

Please sign in to comment.