From c53f06fdc8082add1592872f69af6072557e7c8f Mon Sep 17 00:00:00 2001 From: Chris Bednarski Date: Wed, 26 Feb 2020 21:12:04 -0800 Subject: [PATCH] Moved commands from commands package to root --- commands/commands.go => commands.go | 2 +- commands/commands_test.go => commands_test.go | 2 +- main.go | 27 ++++++++++--------- 3 files changed, 16 insertions(+), 15 deletions(-) rename commands/commands.go => commands.go (99%) rename commands/commands_test.go => commands_test.go (96%) diff --git a/commands/commands.go b/commands.go similarity index 99% rename from commands/commands.go rename to commands.go index bd89608..6816b6b 100644 --- a/commands/commands.go +++ b/commands.go @@ -1,4 +1,4 @@ -package commands +package main import ( "bytes" diff --git a/commands/commands_test.go b/commands_test.go similarity index 96% rename from commands/commands_test.go rename to commands_test.go index fd2e468..ba7f0a0 100644 --- a/commands/commands_test.go +++ b/commands_test.go @@ -1,4 +1,4 @@ -package commands +package main import ( "testing" diff --git a/main.go b/main.go index d61f8f8..e3b7969 100644 --- a/main.go +++ b/main.go @@ -1,3 +1,5 @@ +// hostess is command-line utility for managing your /etc/hosts file. Works on +// Unixes and Windows. package main import ( @@ -6,7 +8,6 @@ import ( "fmt" "os" - "github.com/cbednarski/hostess/commands" "github.com/cbednarski/hostess/hostess" ) @@ -77,15 +78,15 @@ func wrappedMain() error { return err } - options := &commands.Options{ + options := &Options{ IPVersion: 0, Preview: *preview, } if *ipv4 { - options.IPVersion = options.IPVersion|commands.IPv4 + options.IPVersion = options.IPVersion| IPv4 } if *ipv6 { - options.IPVersion = options.IPVersion|commands.IPv6 + options.IPVersion = options.IPVersion| IPv6 } command := cli.Arg(0) @@ -100,49 +101,49 @@ func wrappedMain() error { return nil case "fmt": - return commands.Format(options) + return Format(options) case "add": if len(cli.Args()) != 2 { return fmt.Errorf("Usage: %s add ", cli.Name()) } - return commands.Add(options, cli.Arg(0), cli.Arg(1)) + return Add(options, cli.Arg(0), cli.Arg(1)) case "rm": if cli.Arg(0) == "" { return CommandUsage(command) } - return commands.Remove(options, cli.Arg(0)) + return Remove(options, cli.Arg(0)) case "on": if cli.Arg(0) == "" { return CommandUsage(command) } - return commands.Enable(options, cli.Arg(0)) + return Enable(options, cli.Arg(0)) case "off": if cli.Arg(0) == "" { return CommandUsage(command) } - return commands.Disable(options, cli.Arg(0)) + return Disable(options, cli.Arg(0)) case "ls": - return commands.List(options) + return List(options) case "has": if cli.Arg(0) == "" { return CommandUsage(command) } - return commands.Has(options, cli.Arg(0)) + return Has(options, cli.Arg(0)) case "dump": - return commands.Dump(options) + return Dump(options) case "apply": if cli.Arg(0) == "" { return fmt.Errorf("Usage: %s apply ", os.Args[0]) } - return commands.Apply(options, cli.Arg(0)) + return Apply(options, cli.Arg(0)) default: return ErrInvalidCommand