Skip to content

Commit

Permalink
Add newline char at end of dapr version output (#1014)
Browse files Browse the repository at this point in the history
* add newline character at end of output of dapr version cmd

Signed-off-by: Mukundan Sundararajan <[email protected]>

* add newline char to dapr --version flag

Signed-off-by: Mukundan Sundararajan <[email protected]>

* refactor version template string

Signed-off-by: Mukundan Sundararajan <[email protected]>
  • Loading branch information
mukundansundar authored Jun 28, 2022
1 parent 23e8b8b commit f58c920
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/dapr.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func Execute(version, apiVersion string) {
}

func setVersion() {
template := fmt.Sprintf("CLI version: %s \nRuntime version: %s", daprVer.CliVersion, daprVer.RuntimeVersion)
template := fmt.Sprintf(cliVersionTemplateString, daprVer.CliVersion, daprVer.RuntimeVersion)
RootCmd.SetVersionTemplate(template)
}

Expand Down
6 changes: 4 additions & 2 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"github.com/dapr/cli/pkg/print"
)

const cliVersionTemplateString = "CLI version: %s \nRuntime version: %s\n"

var output string

var VersionCmd = &cobra.Command{
Expand All @@ -40,15 +42,15 @@ dapr version --output json
switch output {
case "":
// normal output.
fmt.Printf("CLI version: %s \nRuntime version: %s", daprVer.CliVersion, daprVer.RuntimeVersion)
fmt.Printf(cliVersionTemplateString, daprVer.CliVersion, daprVer.RuntimeVersion)
case "json":
// json output.
b, err := json.Marshal(daprVer)
if err != nil {
print.FailureStatusEvent(os.Stderr, err.Error())
os.Exit(1)
}
fmt.Printf("%s", string(b))
fmt.Printf("%s\n", string(b))
default:
// fail and exit.
os.Exit(1)
Expand Down

0 comments on commit f58c920

Please sign in to comment.