Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

add version command #210

Closed
wants to merge 3 commits into from
Closed
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
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
# if you want to ignore files created by your editor/tools,
# please consider a global .gitignore https://help.github.com/articles/ignoring-files
# please do not open a pull request to add something created by your editor or tools
dep
testdep
/dep
/testdep
*.exe
1 change: 1 addition & 0 deletions cmd/dep/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func main() {
&ensureCommand{},
&removeCommand{},
&hashinCommand{},
&versionCommand{},
}

usage := func() {
Expand Down
36 changes: 36 additions & 0 deletions cmd/dep/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import (
"flag"
"fmt"

"github.com/golang/dep"
)

const versionShortHelp = `Display version`
const versionLongHelp = `
Display version of this application.
`

const Version = "0.0.1"

func (cmd *versionCommand) Name() string { return "version" }
func (cmd *versionCommand) Args() string { return "" }
func (cmd *versionCommand) ShortHelp() string { return versionShortHelp }
func (cmd *versionCommand) LongHelp() string { return versionLongHelp }
func (cmd *versionCommand) Hidden() bool { return false }

func (cmd *versionCommand) Register(fs *flag.FlagSet) {
}

type versionCommand struct {
}

func (cmd *versionCommand) Run(ctx *dep.Ctx, args []string) error {
fmt.Println(Version)
return nil
}