+
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
4 changes: 1 addition & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
before:
hooks:
- go mod tidy
project_name: goodhosts
builds:
- env:
- GO111MODULE=on
Expand Down
46 changes: 24 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,30 @@ architecture. Unzip and run in place, put in your system path (linux: `/usr/loca
For full usage directions simply call `goodhosts -h`

```shell
$ ./goodhosts -h
NAME:
goodhosts - manage your hosts file goodly

USAGE:
goodhosts [global options] command [command options] [arguments...]

COMMANDS:
check, c Check if ip or host exists
list, ls List all entries in the hostsfile
add, a Add an entry to the hostsfile
remove, rm, r Remove ip or host(s) if exists
debug, d Show debug table for hosts file
backup Backup hosts file
restore Restore hosts file from backup
help, h Shows a list of commands or help for one command

GLOBAL OPTIONS:
--custom value override the default hosts file
--debug, -d Turn on verbose debug logging (default: false)
--quiet, -q Turn on off all logging (default: false)
--help, -h show help (default: false)
$ goodhosts --help
NAME:
goodhosts - manage your hosts file goodly

USAGE:
goodhosts [global options] command [command options] [arguments...]

COMMANDS:
check, c Check if ip or host exists
list, ls List all entries in the hostsfile
add, a Add an entry to the hostsfile
remove, rm, r Remove ip or host(s) if exists
debug, d Show debug table for hosts file
backup Backup hosts file
restore Restore hosts file from backup
edit, e Open hosts file in an editor, default vim
help, h Shows a list of commands or help for one command

GLOBAL OPTIONS:
--file value, -f value override the default hosts: /etc/hosts
--debug, -d Turn on verbose debug logging (default: false)
--quiet, -q Turn on off all logging (default: false)
--help, -h show help (default: false)

```

Each sub-command can be called with a `-h` option to see detailed help information.
Expand Down
4 changes: 2 additions & 2 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ func list(c *cli.Context) error {
}
}

lineOutput := fmt.Sprintf("%s", line.Raw)
lineOutput := fmt.Sprintf("%s\n", line.Raw)
if line.IsMalformed() {
lineOutput = fmt.Sprintf("%s # <<< Malformed!", lineOutput)
lineOutput = fmt.Sprintf("%s # <<< Malformed!\n", lineOutput)
}

logrus.Infof(lineOutput)
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ require (
github.com/goodhosts/hostsfile v0.0.1
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
github.com/urfave/cli/v2 v2.1.1
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 h1:J6v8awz+me+xeb/cUTotKgceAYouhIB3pjzgRd6IlGk=
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816/go.mod h1:tzym/CEb5jnFI+Q0k4Qq3+LvRF4gO3E2pxS8fHP8jcA=
github.com/urfave/cli/v2 v2.1.1 h1:Qt8FeAtxE/vfdrLmR3rxR6JRE0RoVmbXu8+6kZtYU4k=
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
Expand Down
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/goodhosts/cli/cmd"
"github.com/goodhosts/hostsfile"
"github.com/sirupsen/logrus"
easy "github.com/t-tomalak/logrus-easy-formatter"
"github.com/urfave/cli/v2"
)

Expand All @@ -20,6 +21,11 @@ func main() {
Before: func(ctx *cli.Context) error {
if ctx.Bool("debug") {
logrus.SetLevel(logrus.DebugLevel)
} else {
// treat logrus like fmt.Print
logrus.SetFormatter(&easy.Formatter{
LogFormat: "%msg%",
})
}
if ctx.Bool("quiet") {
logrus.SetOutput(ioutil.Discard)
Expand Down

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

21 changes: 21 additions & 0 deletions vendor/github.com/t-tomalak/logrus-easy-formatter/LICENSE

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

81 changes: 81 additions & 0 deletions vendor/github.com/t-tomalak/logrus-easy-formatter/README.md

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

61 changes: 61 additions & 0 deletions vendor/github.com/t-tomalak/logrus-easy-formatter/formatter.go

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

5 changes: 5 additions & 0 deletions vendor/github.com/t-tomalak/logrus-easy-formatter/go.mod

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

9 changes: 9 additions & 0 deletions vendor/github.com/t-tomalak/logrus-easy-formatter/go.sum

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

2 changes: 2 additions & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ github.com/russross/blackfriday/v2
github.com/shurcooL/sanitized_anchor_name
# github.com/sirupsen/logrus v1.4.2
github.com/sirupsen/logrus
# github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816
github.com/t-tomalak/logrus-easy-formatter
# github.com/urfave/cli/v2 v2.1.1
github.com/urfave/cli/v2
# golang.org/x/sys v0.0.0-20190422165155-953cdadca894
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载