Skip to content

Console Commands

Debby includes a powerful command line interface (CLI) accessible through the Console module. This CLI allows you to interact with any adjustable value or method from the Adjust module which has the Command parameter set.

Console CLI

Overview

The CLI provides:

  • Get values: Print the current value of any adjustable
  • Set values: Modify adjustable values with string input
  • Invoke methods: Call adjustable actions from the command line
  • Tab completion: Auto-complete command names

Exposing Adjustables to the CLI

To make an adjustable accessible from the CLI, use the Command parameter in the [Adjust] attribute:

csharp
using Debology.Debby.Modules.Adjust.Attributes;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    [Adjust(Command = "health")]
    private int _health = 100;

    [Adjust(Command = "speed")]
    private float _moveSpeed = 5.0f;

    [Adjust(Command = "godmode")]
    private bool _isInvincible = false;

    [Adjust(Command = "heal")]
    private void Heal()
    {
        _health = 100;
        Debug.Log("Player healed!");
    }
    
    [Adjust(Command = "damage_over_time")]
    private async Task TakeDamageOverTime()
    {
        for(int i = 0; i < 10; i++)
        {
            await Task.Delay(1000);
            _health -= 10;
            Debug.Log($"Player took 10 damage. Health: {_health}");
        }
    }
}

Using Command Prefixes

For better organization, especially when multiple contexts have similar commands, use the CommandPrefix parameter in the [AdjustContext] attribute:

csharp
[AdjustContext(CommandPrefix = "player")]
public class PlayerContext
{
    [Adjust(Command = "health")]
    public int Health { get; set; } = 100;

    [Adjust(Command = "kill")]
    public void Kill() => Health = 0;
}

[AdjustContext(CommandPrefix = "enemy")]
public class EnemyContext
{
    [Adjust(Command = "health")]
    public int Health { get; set; } = 50;

    [Adjust(Command = "kill")]
    public void KillAll() => Debug.Log("All enemies killed!");
}

Console commands:

> player.health         // Get player health
> player.health 100     // Set player health to 100
> player.kill           // Kill player
> enemy.health          // Get enemy health
> enemy.kill            // Kill all enemies

Without prefixes, both contexts would have conflicting "health" and "kill" commands. With prefixes, they're clearly separated.

Command Syntax

Getting Values

To print the current value of an adjustable, type its command name:

> health
health: 100

> speed
speed: 5.0

> position
position: Vector3(10.5, 0, 23.2)

Setting Values

To set a value, type the command name followed by the new value:

> health 50
> health: 50

> speed 10.5
> speed: 10.5

> position 0,5,0
> position: Vector3(0, 5, 0)

The format for complex types depends on the type adapter. Common formats:

  • Vectors: x,y,z (e.g., position 1,2,3)
  • Colors: r,g,b,a (e.g., color 1,0,0,1)
  • Custom types: Check the type adapter's FormatHint

TIP

If you're not sure of the format, Debby will print it if it fails to convert your string to data.

Invoking Methods

To call a method, type its command name:

> heal
> Player healed!

> respawn
> Player respawned at checkpoint

> save
> Game saved successfully

INFO

For async methods, Debby shows a toast notification while the operation runs:

Built-in Commands

help

Displays usage information and available internal commands.

> help
You can use the Debby CLI to set / invoke any adjustable from the Adjust module.
To expose an adjustable to the CLI use the Command field [Adjust(Command = "command_name")].
Available internal commands:
    help - Prints this message
    list - Prints all available commands

list

Lists all registered commands in alphabetical order.

> list
Available commands:
    - difficulty
    - godmode
    - health
    - heal
    - player.kill
    - respawn
    - speed

echo

Prints the provided text to the console. Useful for scripts or logging.

> echo Starting test sequence
Starting test sequence

> echo Health check complete
Health check complete

Tab Completion

Press Tab while typing to auto-complete command names:

> hea[Tab]
> health

> pl[Tab]
> player.

INFO

If multiple commands match, pressing Tab completes up to the longest common prefix:

Custom Types

The CLI uses the cutom type adapter's ToString and FromString methods to convert between strings for the CLI and the adjustable value. See the Custom Types documentation page for more information.

Best Practices

Organize with Prefixes

csharp
// Group related commands under a prefix
[AdjustContext(CommandPrefix = "player")]
public class PlayerContext { }

[AdjustContext(CommandPrefix = "game")]
public class GameContext { }

[AdjustContext(CommandPrefix = "debug")]
public class DebugContext { }

Use Lowercase and Underscore

Commands are case-insensitive, but lowercase is conventional.

csharp
[Adjust(Command = "health")]
[Adjust(Command = "max_health")]
[Adjust(Command = "heal_player")]

Provide Feedback for Actions

When creating command-invokable methods, log results:

csharp
[Adjust(Command = "save")]
private void SaveGame()
{
    // ... save logic ...
    Debug.Log("Game saved successfully!");
}

[Adjust(Command = "heal")]
private void Heal()
{
    Health = MaxHealth;
    Debug.Log($"Healed to {Health} HP");
}

Conditional Commands

Expose commands only in development builds:

csharp
public class DevCommands
{
#if DEVELOPMENT_BUILD || UNITY_EDITOR
    [Adjust(Command = "unlockall")]
    private void UnlockAll() { }

    [Adjust(Command = "skiptime")]
    private void SkipTime(float hours) { }
#endif
}

Dynamic Command Registration

For builder-pattern contexts, you can still use commands:

csharp
var health = new AdjustableValue<int>(100);
Debby.Adjust.NewContext("Player")
    .AddValue("Health", health, new AdjustAttribute { Command = "health" })
    .Build();

Troubleshooting

Command not found:

  • Verify the Command parameter is set in the [Adjust] attribute
  • Check that the context has been registered with Debby.Adjust.RegisterContext()
  • Check if a command prefix is set in [AdjustContext]
  • Use the list command to see all available commands