command

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2017 License: GPL-3.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

View Source
const Name string = "hostBuilder"

Name is the name of this program

View Source
const Version string = "0.3.2"

Version is the current version

Variables

View Source
var Commands = []cli.Command{
	{
		Name:         "createConfig",
		Aliases:      []string{"c"},
		Usage:        "Create a config file from an existing hosts file",
		Action:       CmdCreateConfig,
		BashComplete: CompleteCreateConfig,
		Flags: []cli.Flag{
			cli.StringFlag{
				Name:  "hostsFile, hosts",
				Usage: "The path to your hosts file",
				Value: "/etc/hosts",
			},
		},
	},
	{
		Name:         "build",
		Aliases:      []string{"b"},
		Usage:        "Builds your host file",
		Action:       CmdBuild,
		BashComplete: CompleteBuild,
		Flags: []cli.Flag{
			cli.StringFlag{
				Name:   "output, o",
				Usage:  "The path to write your hosts file",
				EnvVar: "HOST_BUILDER_OUTPUT_FILE",
			},
			cli.BoolFlag{
				Name:  "oneLinePerIP",
				Usage: "Put all hosts for an IP on the same line",
			},
		},
	},
	{
		Name:         "globalIP",
		Aliases:      []string{"gl"},
		Usage:        "Add things to the configuration",
		Category:     "Config",
		BashComplete: RootCompletion,
		Subcommands: []cli.Command{
			{
				Name:         "add",
				Aliases:      []string{"a"},
				Usage:        "Add a global IP to the configuration",
				Action:       CmdGlobalIPAdd,
				BashComplete: CompleteGlobalIPAdd,
				Flags:        []cli.Flag{forceFlag},
			},
			{
				Name:         "remove",
				Aliases:      []string{"r"},
				Usage:        "Remove a global IP from the configuration",
				Action:       CmdGlobalIPRemove,
				BashComplete: CompleteGlobalIPRemove,
			},
			{
				Name:    "list",
				Aliases: []string{"l"},
				Usage:   "List global IPs in the configuration",
				Action:  CmdGlobalIPList,
			},
		},
	},
	{
		Name:         "host",
		Aliases:      []string{"ho"},
		Usage:        "Modify hosts",
		Category:     "Config",
		BashComplete: RootCompletion,
		Subcommands: []cli.Command{
			{
				Name:         "add",
				Aliases:      []string{"a"},
				Usage:        "Add an IP to a hostname",
				Action:       CmdHostAdd,
				BashComplete: CompleteHostAdd,
				Flags:        []cli.Flag{forceFlag},
			},
			{
				Name:         "remove",
				Aliases:      []string{"r"},
				Usage:        "Remove an IP from a hostname",
				Action:       CmdHostRemove,
				BashComplete: CompleteHostRemove,
			},
			{
				Name:    "list",
				Aliases: []string{"l"},
				Usage:   "List the available hostnames",
				Action:  CmdHostList,
			},
			{
				Name:         "show",
				Aliases:      []string{"sh"},
				Usage:        "Describe the IPs on a hostname",
				Action:       CmdHostShow,
				BashComplete: CompleteHostShow,
			},
			{
				Name:         "set",
				Aliases:      []string{"se"},
				Usage:        "Set a hostname to a specific ip",
				Action:       CmdHostSet,
				BashComplete: CompleteHostSet,
			},
		},
	},
	{
		Name:         "group",
		Aliases:      []string{"gr"},
		Usage:        "Modify groups",
		Category:     "Config",
		BashComplete: RootCompletion,
		Subcommands: []cli.Command{
			{
				Name:         "add",
				Aliases:      []string{"a"},
				Usage:        "Add a hostname to a group",
				Action:       CmdGroupAdd,
				BashComplete: CompleteGroupAdd,
			},
			{
				Name:    "list",
				Aliases: []string{"l"},
				Usage:   "List available groups",
				Action:  CmdGroupList,
			},
			{
				Name:         "show",
				Aliases:      []string{"sh"},
				Usage:        "List the hostnames in a group",
				Action:       CmdGroupShow,
				BashComplete: CompleteGroupShow,
			},
			{
				Name:         "set",
				Aliases:      []string{"se"},
				Usage:        "Set the hostnames in a group to a global ip",
				Action:       CmdGroupSet,
				BashComplete: CompleteGroupSet,
			},
		},
	},
	{
		Name:         "aws",
		Aliases:      []string{"a"},
		Usage:        "Add information from AWS to the configuration",
		Category:     "Config",
		BashComplete: RootCompletion,
		Subcommands: []cli.Command{
			{
				Name:         "loadBalancers",
				Aliases:      []string{"l", "lb"},
				Usage:        "Add load balancer information to the configuration",
				Action:       CmdAwsLoadBalancer(new(awsUtil.AwsUtil)),
				BashComplete: CompleteAwsLoadBalancer(new(awsUtil.AwsUtil)),
				Flags:        []cli.Flag{profileFlag},
			},
			{
				Name:         "instances",
				Aliases:      []string{"i"},
				Usage:        "Add instance information to the configuration",
				Action:       CmdAwsInstances(new(awsUtil.AwsUtil)),
				BashComplete: CompleteAwsInstances(new(awsUtil.AwsUtil)),
				Flags: []cli.Flag{
					profileFlag,
					cli.StringFlag{
						Name:   "template, t",
						Usage:  "The template to use for naming instance ips",
						EnvVar: "HOST_BUILDER_INSTANCE_TEMPLATE",
						Value:  "{{.InstanceId}}",
					},
				},
			},
		},
	},
}

Commands defines the commands that can be called on hostBuilder

View Source
var GlobalFlags = []cli.Flag{
	cli.StringFlag{
		Name:   "config, c",
		Usage:  "The path to your config file",
		EnvVar: "HOST_BUILDER_CONFIG_FILE",
	},
}

GlobalFlags defines flags that apply to all commands

Functions

func CmdAwsInstances

func CmdAwsInstances(util awsUtil.AwsInterface) func(c *cli.Context) error

CmdAwsInstances adds aws instance information to the configuration

func CmdAwsInstancesHelper

func CmdAwsInstancesHelper(c *cli.Context, util awsUtil.AwsInterface) error

CmdAwsInstancesHelper uses the given awsUtil to add aws instance information to the configuration

func CmdAwsLoadBalancer

func CmdAwsLoadBalancer(util awsUtil.AwsInterface) func(*cli.Context) error

CmdAwsLoadBalancer adds aws load balancer information to the configuration

func CmdAwsLoadBalancerHelper

func CmdAwsLoadBalancerHelper(c *cli.Context, util awsUtil.AwsInterface) error

CmdAwsLoadBalancerHelper uses the given awsUtil to add aws load balancer information to the configuration

func CmdBuild

func CmdBuild(c *cli.Context) error

CmdBuild builds the hostfile from a configuration file

func CmdCreateConfig

func CmdCreateConfig(c *cli.Context) error

CmdCreateConfig creates a config file from an existing hosts file

func CmdGlobalIPAdd

func CmdGlobalIPAdd(c *cli.Context) error

CmdGlobalIPAdd adds an ip to the global ip list

func CmdGlobalIPList

func CmdGlobalIPList(c *cli.Context) error

CmdGlobalIPList adds an ip to the global ip list

func CmdGlobalIPRemove

func CmdGlobalIPRemove(c *cli.Context) error

CmdGlobalIPRemove adds an ip to the global ip list

func CmdGroupAdd

func CmdGroupAdd(c *cli.Context) error

CmdGroupAdd adds a hostname to a group

func CmdGroupList

func CmdGroupList(c *cli.Context) error

CmdGroupList lists the groups in the configuration

func CmdGroupSet

func CmdGroupSet(c *cli.Context) error

CmdGroupSet sets the hostnames in a group to a global ip

func CmdGroupShow

func CmdGroupShow(c *cli.Context) error

CmdGroupShow lists the hostnames in a group

func CmdHostAdd

func CmdHostAdd(c *cli.Context) error

CmdHostAdd adds an IP to a hostname

func CmdHostList

func CmdHostList(c *cli.Context) error

CmdHostList lists the hostNames in the configuration

func CmdHostRemove

func CmdHostRemove(c *cli.Context) error

CmdHostRemove removes a host from the configuration

func CmdHostSet

func CmdHostSet(c *cli.Context) error

CmdHostSet sets the current IP on a hostname

func CmdHostShow

func CmdHostShow(c *cli.Context) error

CmdHostShow describes the current state of a host

func CompleteAwsInstances

func CompleteAwsInstances(util awsUtil.AwsInterface) func(c *cli.Context)

CompleteAwsInstances handles bash autocompletion for the 'aws instances' command

func CompleteAwsInstancesHelper

func CompleteAwsInstancesHelper(c *cli.Context, util awsUtil.AwsInterface)

CompleteAwsInstancesHelper handles bash autocompletion for the 'aws instances' command

func CompleteAwsLoadBalancer

func CompleteAwsLoadBalancer(util awsUtil.AwsInterface) func(c *cli.Context)

CompleteAwsLoadBalancer handles bash autocompletion for the 'aws loadBalancers' command

func CompleteAwsLoadBalancerHelper

func CompleteAwsLoadBalancerHelper(c *cli.Context, util awsUtil.AwsInterface)

CompleteAwsLoadBalancerHelper handles bash autocompletion for the 'aws instances' command

func CompleteBuild

func CompleteBuild(c *cli.Context)

CompleteBuild handles bash autocompletion for the 'build' command

func CompleteCreateConfig

func CompleteCreateConfig(c *cli.Context)

CompleteCreateConfig handles bash autocompletion for the 'createConfig' command

func CompleteGlobalIPAdd

func CompleteGlobalIPAdd(c *cli.Context)

CompleteGlobalIPAdd handles bash autocompletion for the 'globalIP add' command

func CompleteGlobalIPRemove

func CompleteGlobalIPRemove(c *cli.Context)

CompleteGlobalIPRemove handles bash autocompletion for the 'globalIP remove' command

func CompleteGroupAdd

func CompleteGroupAdd(c *cli.Context)

CompleteGroupAdd handles bash autocompletion for the 'group add' command

func CompleteGroupSet

func CompleteGroupSet(c *cli.Context)

CompleteGroupSet handles bash autocompletion for the 'group set' command

func CompleteGroupShow

func CompleteGroupShow(c *cli.Context)

CompleteGroupShow handles bash autocompletion for the 'group show' command

func CompleteHostAdd

func CompleteHostAdd(c *cli.Context)

CompleteHostAdd handles bash autocompletion for the 'host add' command

func CompleteHostRemove

func CompleteHostRemove(c *cli.Context)

CompleteHostRemove handles bash autocompletion for the 'host remove' command

func CompleteHostSet

func CompleteHostSet(c *cli.Context)

CompleteHostSet handles bash autocompletion for the 'host set' command

func CompleteHostShow

func CompleteHostShow(c *cli.Context)

CompleteHostShow handles bash autocompletion for the 'host show' command

func RootCompletion added in v0.3.0

func RootCompletion(c *cli.Context)

RootCompletion prints the list of root commands as the root completion method This is similar to the default method, but it excludes aliases

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL