Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Add version command #22

Merged
merged 1 commit into from
May 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions cmd/coder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import (
"github.com/spf13/pflag"
"go.coder.com/cli"
"log"
"os"
"net/http"
_ "net/http/pprof"
"os"
)

type rootCmd struct {
}
var (
version string
)

type rootCmd struct{}

func (r *rootCmd) Run(fl *pflag.FlagSet) {
fl.Usage()
Expand All @@ -32,6 +35,7 @@ func (r *rootCmd) Subcommands() []cli.Command {
&shellCmd{},
&syncCmd{},
&urlCmd{},
&versionCmd{},
}
}

Expand Down
27 changes: 27 additions & 0 deletions cmd/coder/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package main

import (
"fmt"
"runtime"

"github.com/spf13/pflag"
"go.coder.com/cli"
)

type versionCmd struct{}

func (versionCmd) Spec() cli.CommandSpec {
return cli.CommandSpec{
Name: "version",
Usage: "",
Desc: "Print the currently installed CLI version",
}
}

func (versionCmd) Run(fl *pflag.FlagSet) {
fmt.Println(
version,
runtime.Version(),
runtime.GOOS+"/"+runtime.GOARCH,
)
}