Skip to content

Commit 745f771

Browse files
committed
refactor: update code
1 parent f3e2005 commit 745f771

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ osbuilder 具有以下功能特点:
4343
### 安装
4444

4545
```bash
46-
$ curl -fsSL https://raw.githubusercontent.com/onexstack/osbuilder/master/scripts/install.sh | bash
46+
go install github.com/onexstack/osbuilder/cmd/osbuilder@latest
4747
$ osbuilder version
4848
```
4949

internal/osbuilder/cmd/version/version.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ var versionExample = templates.Examples(`
3434

3535
// Options is a struct to support version command.
3636
type Options struct {
37-
ClientOnly bool
38-
Short bool
39-
Output string
37+
Short bool
38+
Output string
4039

4140
genericiooptions.IOStreams
4241
}
@@ -53,8 +52,8 @@ func NewCmdVersion(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cob
5352
o := NewOptions(ioStreams)
5453
cmd := &cobra.Command{
5554
Use: "version",
56-
Short: "Print the client and server version information",
57-
Long: "Print the client and server version information for the current context",
55+
Short: "Print the client version information",
56+
Long: "Print the client version information for the current context",
5857
Example: versionExample,
5958
Run: func(cmd *cobra.Command, args []string) {
6059
cmdutil.CheckErr(o.Complete(f, cmd))
@@ -63,7 +62,6 @@ func NewCmdVersion(f cmdutil.Factory, ioStreams genericiooptions.IOStreams) *cob
6362
},
6463
}
6564

66-
cmd.Flags().BoolVar(&o.ClientOnly, "client", o.ClientOnly, "If true, shows client version only (no server required).")
6765
cmd.Flags().StringVarP(&o.Output, "output", "o", o.Output, "One of 'yaml' or 'json'.")
6866
cmd.Flags().BoolVar(&o.Short, "short", o.Short, "If true, print just the version number.")
6967

@@ -99,9 +97,9 @@ func (o *Options) Run() error {
9997
switch o.Output {
10098
case "":
10199
if o.Short {
102-
fmt.Fprintf(o.Out, "Client Version: %s\n", clientVersion.GitVersion)
100+
fmt.Fprintf(o.Out, "%s\n", clientVersion.String())
103101
} else {
104-
fmt.Fprintf(o.Out, "Client Version: %s\n", fmt.Sprintf("%#v", clientVersion))
102+
fmt.Fprintf(o.Out, "Client Version: %s\n", clientVersion.ToJSON())
105103
}
106104
case "yaml":
107105
marshaled, err := yaml.Marshal(&versionInfo)

0 commit comments

Comments
 (0)