Arguments

run maps CLI arguments into shell variables based on the function signature. This page covers how parameters, defaults, and rest arguments work.

Parameter mapping

  • Signature parameters become shell variables with the same name.
    greet(name) echo "Hello, $name!"
    # run greet Alice  -> prints "Hello, Alice!"
    
  • Parameters stay positional: the first CLI token maps to the first parameter, and so on.
  • Legacy $1, $2, $@ work alongside named parameters for backward compatibility.

Defaults and required parameters

  • Provide defaults in the signature to make parameters optional:
    deploy(env, version = "latest") echo "Deploying $version to $env"
    # run deploy staging        -> uses version "latest"
    # run deploy staging v1.2.3 -> overrides the default
    
  • Calls missing a required argument fail before execution.
  • Default values may be quoted; the target shell expands them.

Rest parameters

Capture any remaining arguments into one variable:

echo_all(...args) echo "Args: $args"
# run echo_all foo bar -> Args: foo bar

Polyglot parameter mapping

Named parameters also work in Python, Node.js, and Ruby functions. run auto-generates variable declarations so you can use parameter names directly:

# @shell python
greet(name, greeting = "Hello") {
    print(f"{greeting}, {name}!")
}

Type hints apply real conversions in polyglot scripts: int wraps in int()/parseInt()/.to_i, float wraps in float()/parseFloat()/.to_f, bool performs truth-checking, and object parses a JSON string via json.loads()/JSON.parse(). See Polyglot commands for the full mapping table.

Types in signatures

Type hints (str, int, float/number, bool, object/obj/dict) are used for MCP schema generation. In shell functions, conversion is up to your script. In polyglot functions (Python, Node.js, Ruby), typed parameters are automatically converted when injected:

  • int/integer — parsed as an integer
  • float/number — parsed as a floating-point number
  • bool/boolean — parsed as a boolean (truthy: true, 1, yes)
  • object/obj/dict — parsed from a JSON string into a native object/dict

Quoting and spaces

Arguments are passed as plain CLI tokens. Quote values containing spaces or shell-sensitive characters:

run deploy "staging us-east" "v1.2.3"

See Variables for environment handling and variable resolution.