[][src]Trait duckscript::types::command::Command

pub trait Command {
    fn name(&self) -> String;
fn clone_and_box(&self) -> Box<dyn Command>; fn aliases(&self) -> Vec<String> { ... }
fn help(&self) -> String { ... }
fn requires_context(&self) -> bool { ... }
fn run(&self, _arguments: Vec<String>) -> CommandResult { ... }
fn run_with_context(
        &self,
        _arguments: Vec<String>,
        _state: &mut HashMap<String, StateValue>,
        _variables: &mut HashMap<String, String>,
        _output_variable: Option<String>,
        _instructions: &Vec<Instruction>,
        _commands: &mut Commands,
        _line: usize
    ) -> CommandResult { ... } }

Defines the command capabilities

Required methods

fn name(&self) -> String

The full command name which can be used to invoke this command.

fn clone_and_box(&self) -> Box<dyn Command>

Clones the command and returns a box reference.

Loading content...

Provided methods

fn aliases(&self) -> Vec<String>

A list of aliases that can also be used to invoke this command.

fn help(&self) -> String

Command documentation.

fn requires_context(&self) -> bool

If true the run with the context will be invoked.

fn run(&self, _arguments: Vec<String>) -> CommandResult

Runs the given instruction

fn run_with_context(
    &self,
    _arguments: Vec<String>,
    _state: &mut HashMap<String, StateValue>,
    _variables: &mut HashMap<String, String>,
    _output_variable: Option<String>,
    _instructions: &Vec<Instruction>,
    _commands: &mut Commands,
    _line: usize
) -> CommandResult

Run the instruction with access to the runtime context.

Arguments

  • arguments - The command arguments array
  • state - Internal state which is only used by commands to store/pull data
  • variables - All script variables
  • output_variable - The output variable name (if defined)
  • instructions - The entire list of instructions which make up the currently running script
  • commands - The currently known commands
  • line - The current instruction line number (global line number after including all scripts into one global script)
Loading content...

Implementors

Loading content...