Skip to main content
The palyra CLI serves as the primary administrative and operational interface for the Palyra ecosystem. It is built using the clap library for robust argument parsing and supports a deeply nested command tree designed for managing local runtimes, remote nodes, and security policies.

CLI Architecture and Implementation

The CLI is structured to separate argument definition, command dispatch, and transport logic. It utilizes a “Command” pattern where the parsed Cli struct determines which internal module handles the request.

Command Execution Flow

The entry point in crates/palyra-cli/src/lib.rs initializes the runtime and dispatches to specific command handlers.
  1. Parsing: clap derives the Cli structure from crates/palyra-cli/src/args/mod.rs crates/palyra-cli/src/args/mod.rs#1-44.
  2. Context Resolution: The CLI determines the RootContext, which includes loading the palyra.toml configuration and identifying the target daemon (local vs. remote) crates/palyra-cli/src/lib.rs#7-12.
  3. Dispatch: The match statement in the main execution loop routes the command to the appropriate module in crates/palyra-cli/src/commands/ crates/palyra-cli/src/commands/mod.rs#1-50.
  4. Transport: Commands interact with the daemon via either the Admin/Console HTTP API (using reqwest) or the Gateway gRPC Service (using tonic) crates/palyra-cli/src/lib.rs#15-59.

CLI Component Mapping

The following diagram maps CLI logical components to their implementation files and structures. CLI Entity Mapping Sources: crates/palyra-cli/src/lib.rs#76-90, crates/palyra-cli/src/args/mod.rs#1-44, crates/palyra-cli/src/commands/mod.rs#1-50

Global Flags and Configuration

The CLI supports several global options that modify behavior across all subcommands.
FlagEnv VarDescription
--config <PATH>PALYRA_CONFIGPath to palyra.toml crates/palyra-cli/src/lib.rs#62-63.
--profile <NAME>PALYRA_PROFILESelects a specific configuration profile (e.g., staging).
--state-root <DIR>PALYRA_STATE_ROOTOverrides the directory for identity and local state.
--output-formatPALYRA_OUTPUTOptions: text (default), json, ndjson crates/palyra-cli/tests/help_snapshots/root-help-unix.txt#73-75.
--verbose, -vPALYRA_LOGIncreases logging verbosity (debug/trace).
Sources: crates/palyra-cli/tests/help_snapshots/root-help-unix.txt#59-80

Primary Command Tree

The CLI organizes commands into functional families.

1. Setup and Diagnostics

2. Runtime and Gateway

3. Security and Secrets

4. Memory and Intelligence

Sources: crates/palyra-cli/tests/help_snapshots/root-help-unix.txt#5-54, crates/palyra-cli/src/commands/mod.rs#1-50

Secret Management and Vault Interaction

The secrets command family interacts directly with the palyra-vault crate. It supports both interactive configuration and offline auditing of configuration files to ensure no raw secrets are stored in palyra.toml. Secret Audit and Apply Logic Sources: crates/palyra-cli/src/commands/secrets.rs#147-163, crates/palyra-cli/tests/secrets_cli.rs#144-184

Cross-Platform Parity Testing

To ensure consistent behavior across Windows, macOS, and Linux, Palyra employs a CLI Parity Matrix. This system snapshots the --help output and argument parsing behavior for every command. Sources: crates/palyra-cli/tests/help_snapshots.rs#1-127, crates/palyra-cli/src/cli_parity.rs#1-20