commands

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2016 License: GPL-3.0 Imports: 18 Imported by: 3

README

#RITA Commands

###Hacking

####Some things to remember Commands should behave like typical Unix systems commands. For example, the human readable output from show-beacons or show-scans is MUCH easier to read... but the default is just an unformatted comma delimited list which looks like garbage. The latter option is much easier to parse with sed, awk, cut, etc...

We've tried to make adding commands to rita easier. Here's a quick rundown of how a command might be added to the system.

  1. Create a new command file in the commands directory called "nameofcommand.go"
  2. Create an init function in this command that declares your command and adds it to the allCommands global.
  3. Create a function that executes the business logic of your command.
  4. Profit.
func init() {
	command := cli.Command{
		Flags: []cli.Flags{
			cli.IntFlag{
				Name: "test, t",
				Usage: "set test flag",
				Value: 29,
			},
			// There are also a few pre-defined flags for you to use
			configFlag,
		},
		Name: "nameofcommand",
		Usage: "how to use the command",
		Action: nameOfCmdFunc,
	}

	// Add the command to the allCommands data structure (IMPORTANT)
	allCommands = append(allCommands, command)
}

// It is very important that we use a function of this type (for compatibility with cli)
func nameOfCmdFunc(c *cli.Context) error {
	// do stuff
	return nil
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Commands

func Commands() []cli.Command

Commands provides all of the defined commands to the front end

Types

This section is empty.

Jump to

Keyboard shortcuts

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