Skip to content

Commit 32d25e2

Browse files
authored
Merge pull request #18 from luthermonson/master
Add Version Command and Vendor v0.0.7 hostsfile
2 parents f4b79f6 + c978af6 commit 32d25e2

7 files changed

Lines changed: 50 additions & 11 deletions

File tree

cmd/main.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@ func Run(c *cli.Context) error {
1717

1818
func Commands() []*cli.Command {
1919
return []*cli.Command{
20+
Add(),
21+
Backup(),
2022
Check(),
23+
Clean(),
24+
Debug(),
25+
Edit(),
2126
List(),
22-
Add(),
2327
Remove(),
24-
Debug(),
25-
Backup(),
2628
Restore(),
27-
Edit(),
28-
Clean(),
29+
Version(),
2930
}
3031
}
3132

cmd/version.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package cmd
2+
3+
import (
4+
"github.com/sirupsen/logrus"
5+
"github.com/urfave/cli/v2"
6+
)
7+
8+
func Version() *cli.Command {
9+
return &cli.Command{
10+
Name: "version",
11+
Usage: "",
12+
Action: version,
13+
}
14+
}
15+
16+
func version(c *cli.Context) error {
17+
logrus.Infof("goodhosts %s", c.Context.Value("version"))
18+
return nil
19+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/goodhosts/cli
33
go 1.13
44

55
require (
6-
github.com/goodhosts/hostsfile v0.0.6
6+
github.com/goodhosts/hostsfile v0.0.7
77
github.com/olekukonko/tablewriter v0.0.4
88
github.com/sirupsen/logrus v1.4.2
99
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
55
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
66
github.com/dimchansky/utfbom v1.1.0 h1:FcM3g+nofKgUteL8dm/UpdRXNC9KmADgTpLKsu0TRo4=
77
github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8=
8-
github.com/goodhosts/hostsfile v0.0.6 h1:th49slfHTGLbSon0bR7jbBiBl5EpjFB42WzS//P3jVg=
9-
github.com/goodhosts/hostsfile v0.0.6/go.mod h1:MAfdBdP0f9MVmfhmNP4EjQxPu7J/WnncHv8p/J8hkLs=
8+
github.com/goodhosts/hostsfile v0.0.7 h1:5yBaORuv1dybDhDRju32bQQ1l4iHKJs+h6GIgFV4qJQ=
9+
github.com/goodhosts/hostsfile v0.0.7/go.mod h1:MAfdBdP0f9MVmfhmNP4EjQxPu7J/WnncHv8p/J8hkLs=
1010
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
1111
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
1212
github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54=

main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"context"
45
"fmt"
56
"io/ioutil"
67
"os"
@@ -12,13 +13,16 @@ import (
1213
"github.com/urfave/cli/v2"
1314
)
1415

16+
var version = "dev"
17+
1518
func main() {
1619
app := &cli.App{
1720
Name: "goodhosts",
1821
Usage: "manage your hosts file goodly",
1922
Action: cmd.DefaultAction,
2023
Commands: cmd.Commands(),
2124
Before: func(ctx *cli.Context) error {
25+
ctx.Context = context.WithValue(ctx.Context, "version", version)
2226
if ctx.Bool("debug") {
2327
logrus.SetLevel(logrus.DebugLevel)
2428
} else {

vendor/github.com/goodhosts/hostsfile/hosts.go

Lines changed: 17 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
github.com/cpuguy83/go-md2man/v2/md2man
33
# github.com/dimchansky/utfbom v1.1.0
44
github.com/dimchansky/utfbom
5-
# github.com/goodhosts/hostsfile v0.0.6
5+
# github.com/goodhosts/hostsfile v0.0.7
66
github.com/goodhosts/hostsfile
77
# github.com/konsorten/go-windows-terminal-sequences v1.0.1
88
github.com/konsorten/go-windows-terminal-sequences

0 commit comments

Comments
 (0)