File tree Expand file tree Collapse file tree
github.com/goodhosts/hostsfile Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,15 +17,16 @@ func Run(c *cli.Context) error {
1717
1818func 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
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ module github.com/goodhosts/cli
33go 1.13
44
55require (
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
Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
55github.com/davecgh/go-spew v1.1.1 /go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38 =
66github.com/dimchansky/utfbom v1.1.0 h1:FcM3g+nofKgUteL8dm/UpdRXNC9KmADgTpLKsu0TRo4 =
77github.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 =
1010github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk =
1111github.com/konsorten/go-windows-terminal-sequences v1.0.1 /go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ =
1212github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54 =
Original file line number Diff line number Diff line change 11package main
22
33import (
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+
1518func 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 {
Original file line number Diff line number Diff line change 22github.com/cpuguy83/go-md2man/v2/md2man
33# github.com/dimchansky/utfbom v1.1.0
44github.com/dimchansky/utfbom
5- # github.com/goodhosts/hostsfile v0.0.6
5+ # github.com/goodhosts/hostsfile v0.0.7
66github.com/goodhosts/hostsfile
77# github.com/konsorten/go-windows-terminal-sequences v1.0.1
88github.com/konsorten/go-windows-terminal-sequences
You can’t perform that action at this time.
0 commit comments