Removed -4 and -6 from CLI (these are still usable in the lib)

master
Chris Bednarski 4 years ago
parent 138ef9dcd4
commit c4e4f6d820

@ -60,11 +60,9 @@ hostess may be configured via environment variables.
## IPv4 and IPv6 ## IPv4 and IPv6
Your hosts file _may_ contain overlapping entries where the same hostname points It's possible for your hosts file to include overlapping entries for IPv4 and
to both an IPv4 and IPv6 IP. In this case, hostess commands will apply to both IPv6. This is an uncommon case so the CLI ignores this distinction. The hostess
entries. Typically you won't have this kind of overlap and the default behavior library includes logic that differentiates between these cases.
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.
## Contributing ## Contributing

@ -11,13 +11,7 @@ import (
"github.com/cbednarski/hostess/hostess" "github.com/cbednarski/hostess/hostess"
) )
const (
IPv4 = 1 << iota
IPv6 = 1 << iota
)
type Options struct { type Options struct {
IPVersion int
Preview bool Preview bool
} }

@ -33,8 +33,6 @@ Commands
Flags Flags
-n will preview changes but not rewrite your hosts file -n will preview changes but not rewrite your hosts file
-4 limit changes to IPv4 entries
-6 limit changes to IPv6 entries
Configuration Configuration
@ -67,8 +65,6 @@ func CommandUsage(command string) error {
func wrappedMain(args []string) error { func wrappedMain(args []string) error {
cli := flag.NewFlagSet(args[0], flag.ExitOnError) cli := flag.NewFlagSet(args[0], flag.ExitOnError)
ipv4 := cli.Bool("4", false, "IPv4")
ipv6 := cli.Bool("6", false, "IPv6")
preview := cli.Bool("n", false, "preview") preview := cli.Bool("n", false, "preview")
cli.Usage = func() { cli.Usage = func() {
fmt.Printf(help, hostess.GetHostsPath()) fmt.Printf(help, hostess.GetHostsPath())
@ -79,15 +75,8 @@ func wrappedMain(args []string) error {
} }
options := &Options{ options := &Options{
IPVersion: 0,
Preview: *preview, Preview: *preview,
} }
if *ipv4 {
options.IPVersion = options.IPVersion | IPv4
}
if *ipv6 {
options.IPVersion = options.IPVersion | IPv6
}
command := cli.Arg(0) command := cli.Arg(0)
switch command { switch command {

Loading…
Cancel
Save