66670942dd
- Rewrite CLI to use flag package instead of codegangsta/cli - Move lib to hostess/ and move main.go to project root - Change some of the hostess API to return errors instead of panicking - Remove aff, del, and list commands - Remove -s and -q flags |
4 years ago | |
---|---|---|
commands | 4 years ago | |
.gitignore | 7 years ago | |
.travis.yml | 4 years ago | |
LICENSE | 9 years ago | |
Makefile | 4 years ago | |
README.md | 4 years ago | |
go.mod | 4 years ago | |
main.go | 4 years ago |
README.md
hostess
An idempotent command-line utility for managing your /etc/hosts
file.
hostess add local.example.com 127.0.0.1
hostess add staging.example.com 10.0.2.16
Why? Because you edit /etc/hosts
for development, testing, and debugging.
Because sometimes DNS doesn't work in production. And because editing
/etc/hosts
by hand is a pain. Put hostess in your Makefile
or deploy scripts
and call it a day.
Note: 0.5.0 has backwards incompatible changes in the API and CLI.
Installation
Download a precompiled release from GitHub, or build from source (with a recent version of Go):
go get -u github.com/cbednarski/hostess
Usage
Run hostess
or hostess -h
to see a full list of commands.
Behavior
On unixes, hostess follows the format specified by man hosts
, with one line
per IP address:
127.0.0.1 localhost hostname2 hostname3
127.0.1.1 machine.name
# 10.10.20.30 some.host
On Windows, hostess writes each hostname on its own line.
127.0.0.1 localhost
127.0.0.1 hostname2
127.0.0.1 hostname3
Configuration
You can force hostess to behave one way or the other with HOSTESS_FMT=windows
or HOSTESS_FMT=unix
.
By default, hostess will read / write to /etc/hosts
. You can use the
HOSTESS_PATH
environment variable to provide an alternate path (for testing).
IPv4 and IPv6
Your hosts file may contain overlapping entries where the same hostname points
to both an IPv4 and IPv6 IP. In this case, hostess commands will apply to both
entries. Typically you won't have this kind of overlap and the default behavior
is OK. However, if you need to be more granular you can use -4
or -6
to
limit operations to entries associated with that type of IP.