commands

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

README

Commands

This directory contains all the commands that can be run from the CLI. The child folders are:

Command Folders

  • agent - Commands that are executed in the agent menu
    • all - Commands that are available to all agents no matter the operating system the agent is running on
    • linux - Commands that are available to agents running on Linux
    • windows - Commands that are available to agents running on Windows
  • all -Commands that are available in all menus
  • listeners - Commands that are executed in the listeners menu
  • mainMenu - Commands that are executed in the main menu only. Could not use main because it is a reserved word
  • module - Commands that are executed in the modules menu
  • multi - Commands that are available in multiple menus, but not all menus.

Template

The template file provides an example command that can be used as a starting point for new commands.

Rules

  • A Command's description should be one sentence
  • A Command's usage should follow these rules:
  • The Command should do as much client side validation as possible before making the API call to the server
  • Hyperlinks should be at the end of the Notes section under a "References" heading
  • Commands "Do" functions should only return UserMessages
    • Set the Error field to true when there was an API or parsing error
    • Set the Level field to Info when not enough arguments were provided and when returning the usage

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command interface {
	// Completer returns the data that is displayed in the CLI for tab completion depending on the menu the command is for
	// Errors are not returned to ensure the CLI is not interrupted.
	// Errors are logged and can be viewed by enabling debug output in the CLI
	Completer(m menu.Menu, id uuid.UUID) readline.PrefixCompleterInterface
	// Do executes the command and returns a Response to the caller to facilitate changes in the CLI service
	// m, an optional parameter, is the Menu the command was executed from
	// id, an optional parameter, used to identify a specific Agent, Listener, or Module
	// arguments, and optional, parameter, is the full unparsed string entered on the command line to include the
	// command itself passed into command for processing
	// Errors are returned through the Error and Message fields of the embedded messages.UserMessage struct in the Response struct
	Do(m menu.Menu, id uuid.UUID, arguments string) (response Response)
	// Help returns a help.Help structure that can be used to view a command's Description, Notes, Usage, and an example
	Help(m menu.Menu) help.Help
	// Menu checks to see if the command is supported for the provided menu
	Menu(menu.Menu) bool
	// OS returns the supported operating system the command can be executed on
	OS() os.OS
	// String returns the unique name of the command as a string
	String() string
}

type Repository

type Repository interface {
	Add(cmd Command)
	Get(menu menu.Menu, cmd string) (Command, error)
	GetAll() (commands []Command)
}

Repository is an interface used to add or get, or update CLI commands from a repository

type Response

type Response struct {
	Agent     uuid.UUID
	AgentOS   os.OS
	Completer *readline.PrefixCompleterInterface
	Listener  uuid.UUID
	Menu      menu.Menu
	Message   *message.UserMessage // Message is used to display a message on the CLI; A pointer is used to allow for nil values for evaluation
	Module    uuid.UUID
	Prompt    string
}

Response is used to return multiple values from Command receivers

Directories

Path Synopsis
Package agent contains commands that are only available in the CLI agents menu
Package agent contains commands that are only available in the CLI agents menu
all
Package all contains commands that are only available in the CLI agents menu for all agent operating system types
Package all contains commands that are only available in the CLI agents menu for all agent operating system types
linux
Package linux contains commands that are only available in the CLI agents menu and only for Linux agents
Package linux contains commands that are only available in the CLI agents menu and only for Linux agents
windows
Package windows contains commands that are only available in the CLI agents menu and only for Windows agents
Package windows contains commands that are only available in the CLI agents menu and only for Windows agents
all
Package all contains commands that are available in all CLI menus
Package all contains commands that are available in all CLI menus
Package listeners contains commands that are only available in the CLI listeners menu and submenus
Package listeners contains commands that are only available in the CLI listeners menu and submenus
Package mainMenu contains commands that are only available in the CLI's main menu.
Package mainMenu contains commands that are only available in the CLI's main menu.
Package module contains commands that are only available in the CLI modules menu NOTE: some commands used in the module menu are also used in other menus and can be found in the pkg/cli/commands/multi directory
Package module contains commands that are only available in the CLI modules menu NOTE: some commands used in the module menu are also used in other menus and can be found in the pkg/cli/commands/multi directory
Package multi contains commands that are available in multiple CLI menus, but not all menus.
Package multi contains commands that are available in multiple CLI menus, but not all menus.
run
set
use
Package repository implements an in-memory database that holds a map of Command structures used with the Merlin CLI
Package repository implements an in-memory database that holds a map of Command structures used with the Merlin CLI

Jump to

Keyboard shortcuts

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