Skip to content

Commit

Permalink
Add version command to CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
eadanfahey committed Jun 8, 2020
1 parent 5bb669d commit 55c27c6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cmd/jot/main.go
Expand Up @@ -29,6 +29,13 @@ const (
giB = 1024 * miB
)

// Build flags
var (
Version string
CommitID string
BuildDate string
)

type handler func(*jot.Client, *cli.Context) error

func getLatestVersion(client *jot.Client, name string) (jot.FileInfo, error) {
Expand Down Expand Up @@ -752,6 +759,17 @@ func main() {
},
},
},
{
Name: "version",
Usage: "output version info",
Action: func(c *cli.Context) error {
format := "%-10s: %s\n"
fmt.Printf(format, "Version", Version)
fmt.Printf(format, "Build date", BuildDate)
fmt.Printf(format, "Commit ID", CommitID)
return nil
},
},
}

app.Run(os.Args)
Expand Down

0 comments on commit 55c27c6

Please sign in to comment.