Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
11 changes: 6 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ func Run(c *cli.Context) error {

func Commands() []*cli.Command {
return []*cli.Command{
Add(),
Backup(),
Check(),
Clean(),
Debug(),
Edit(),
List(),
Add(),
Remove(),
Debug(),
Backup(),
Restore(),
Edit(),
Clean(),
Version(),
}
}

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

import (
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)

func Version() *cli.Command {
return &cli.Command{
Name: "version",
Usage: "",
Action: version,
}
}

func version(c *cli.Context) error {
logrus.Infof("goodhosts %s", c.Context.Value("version"))
return nil
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/goodhosts/cli
go 1.13

require (
github.com/goodhosts/hostsfile v0.0.6
github.com/goodhosts/hostsfile v0.0.7
github.com/olekukonko/tablewriter v0.0.4
github.com/sirupsen/logrus v1.4.2
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dimchansky/utfbom v1.1.0 h1:FcM3g+nofKgUteL8dm/UpdRXNC9KmADgTpLKsu0TRo4=
github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8=
github.com/goodhosts/hostsfile v0.0.6 h1:th49slfHTGLbSon0bR7jbBiBl5EpjFB42WzS//P3jVg=
github.com/goodhosts/hostsfile v0.0.6/go.mod h1:MAfdBdP0f9MVmfhmNP4EjQxPu7J/WnncHv8p/J8hkLs=
github.com/goodhosts/hostsfile v0.0.7 h1:5yBaORuv1dybDhDRju32bQQ1l4iHKJs+h6GIgFV4qJQ=
github.com/goodhosts/hostsfile v0.0.7/go.mod h1:MAfdBdP0f9MVmfhmNP4EjQxPu7J/WnncHv8p/J8hkLs=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54=
Expand Down
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"context"
"fmt"
"io/ioutil"
"os"
Expand All @@ -12,13 +13,16 @@ import (
"github.com/urfave/cli/v2"
)

var version = "dev"

func main() {
app := &cli.App{
Name: "goodhosts",
Usage: "manage your hosts file goodly",
Action: cmd.DefaultAction,
Commands: cmd.Commands(),
Before: func(ctx *cli.Context) error {
ctx.Context = context.WithValue(ctx.Context, "version", version)
if ctx.Bool("debug") {
logrus.SetLevel(logrus.DebugLevel)
} else {
Expand Down
19 changes: 17 additions & 2 deletions vendor/github.com/goodhosts/hostsfile/hosts.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
github.com/cpuguy83/go-md2man/v2/md2man
# github.com/dimchansky/utfbom v1.1.0
github.com/dimchansky/utfbom
# github.com/goodhosts/hostsfile v0.0.6
# github.com/goodhosts/hostsfile v0.0.7
github.com/goodhosts/hostsfile
# github.com/konsorten/go-windows-terminal-sequences v1.0.1
github.com/konsorten/go-windows-terminal-sequences
Expand Down