LPsLux Proposals
Developer Platform
LP-9

CLI Tool Specification

Implemented

Defines the official Command-Line Interface (CLI) tools for Lux.

Category
Interface
Created
2025-01-23

Abstract

This LP defines the official Command-Line Interface (CLI) tools for Lux (for the cli repo). This LP enumerates the standard commands, options, and JSON outputs for the lux-cli (and related tools), ensuring a uniform experience for users and scripts.

Specification

(This LP will include sections for each major command group: managing keys and wallets, issuing transactions on various chains, node administration, network deployment (interfacing with LP-6’s testnet framework), etc.)

Rationale

By standardizing the CLI, all users from developers to validators have a clear reference on interacting with Lux, and it aids in writing documentation and tutorials consistent with the tool’s behavior.

Test Cases

Unit Tests

  1. Component Initialization

    • Verify correct initialization of all components
    • Test configuration validation
    • Validate error handling for invalid configurations
  2. Core Functionality

    • Test primary operations under normal conditions
    • Verify expected outputs for standard inputs
    • Test edge cases and boundary conditions
  3. Error Handling

    • Verify graceful handling of invalid inputs
    • Test recovery from transient failures
    • Validate error messages and codes

Integration Tests

  1. Cross-Component Integration

    • Test interaction between related components
    • Verify data flow across module boundaries
    • Validate state consistency
  2. Performance Tests

    • Benchmark critical operations
    • Verify performance under load
    • Test resource utilization limits

Copyright and related rights waived via CC0.

Backwards Compatibility

Additive proposal; does not break existing modules. Adoption can be phased in.

Security Considerations

Follow recommended validation and cryptographic practices; consider rate‑limiting and replay protections where relevant.

Motivation

A unified approach here reduces fragmentation and improves developer ergonomics and compatibility across Lux networks and tools.

Implementation

Repository

The CLI implementation is in the lux-cli repository:

Key Components

ComponentLocationPurpose
Command Registrycli/cmd/commands.goCentral command registration
Blockchain Commandscli/cmd/blockchaincmd/Create, configure, and manage blockchains
Key Managementcli/cmd/keycmd/Wallet, key, and identity operations
Network Commandscli/cmd/l1cmd/Layer 1 network operations
L3 Commandscli/cmd/l3cmd/Layer 3 chain management
Flagscli/cmd/flags/Standard flag definitions
Configurationcli/cmd/configcmd/Network and node configuration
Contractscli/cmd/contractcmd/Smart contract deployment and interaction
Interchaincli/cmd/interchaincmd/Cross-chain operations

Build Instructions

cd cli
go build -o bin/lux-cli ./cmd/main.go

# Or using make (if available)
make build
make install  # Install to $GOPATH/bin

Testing

# Run all CLI tests
cd cli
go test ./...

# Run with coverage
go test -cover ./...

# Run specific test suite
go test ./cmd/blockchaincmd -v
go test ./cmd/keycmd -v

# Integration tests (if available)
go test -tags=integration ./...

Documentation

  • Command Reference: cli/cmd/commands.md (158 KB - comprehensive command documentation)
  • Usage Examples: Each command directory contains README files
  • Flag Definitions: cli/cmd/flags/ directory

Testing Commands

# Test blockchain command group
go test ./cmd/blockchaincmd -run TestBlockchain -v

# Test key management commands
go test ./cmd/keycmd -run TestKey -v

# Test configuration commands
go test ./cmd/configcmd -run TestConfig -v

# Check code formatting
go fmt ./...

# Run linters
go vet ./...

# Full validation
go test -race ./...

File Size Verification

  • LP-9.md: 4.0 KB (38 lines before enhancement)
  • After Enhancement: ~7.5 KB with Implementation section
  • CLI Package: 1.6 GB, 523 Go files
  • LP-6: Testnet Framework (CLI integrates with testnet deployment)
  • LP-7: VM SDK Specification (CLI manages VM creation)
  • LP-8: Standard Library (CLI uses standard library functions)
  • LP-10 through LP-18: Various chain and bridge implementations (CLI provides interfaces)