CLI Mode

The standard command-line interface is the primary way to use RAPS. It’s designed for scripts, automation, and CI/CD pipelines.

Quick Start

# Install RAPS
cargo install raps

# Configure credentials
export APS_CLIENT_ID="your_client_id"
export APS_CLIENT_SECRET="your_client_secret"

# Run commands
raps auth test
raps bucket list

Command Structure

RAPS follows a consistent command structure:

raps <command> <subcommand> [arguments] [flags]

Examples

# Authentication
raps auth test
raps auth login --3lo
raps auth status

# Bucket operations
raps bucket list
raps bucket create my-bucket --retention transient
raps bucket delete my-bucket

# Object operations
raps object upload my-bucket model.rvt
raps object download my-bucket model.rvt
raps object list my-bucket

# Translation
raps translate start <URN> --format svf2
raps translate status <URN> --wait
raps translate manifest <URN>

Output Formats

RAPS supports multiple output formats for easy integration:

# JSON (machine-readable)
raps bucket list --output json

# YAML
raps bucket list --output yaml

# CSV (spreadsheet-friendly)
raps bucket list --output csv

# Table (default, human-readable)
raps bucket list --output table

# Plain text
raps bucket list --output plain

Piping to Other Tools

# Parse JSON with jq
raps bucket list --output json | jq '.[] | .bucketKey'

# Count objects
raps object list my-bucket --output json | jq 'length'

# Filter by pattern
raps object list my-bucket --output json | jq '.[] | select(.objectKey | contains(".rvt"))'

Global Flags

These flags work with all commands:

FlagDescription
--output <format>Output format: json, yaml, csv, table, plain
--no-colorDisable colored output
--quietMinimal output (data only)
--verboseShow request summaries
--debugFull trace with secret redaction
--timeout <seconds>HTTP request timeout (default: 120)
--non-interactiveFail on prompts instead of waiting
--yesAuto-confirm destructive operations

Examples

# Quiet mode for scripts
BUCKET=$(raps bucket list --output json --quiet | jq -r '.[0].bucketKey')

# Debug API calls
raps auth test --debug

# Non-interactive for CI/CD
raps bucket delete my-bucket --yes --non-interactive

Exit Codes

RAPS uses standardized exit codes for scripting:

CodeMeaning
0Success
2Invalid arguments
3Authentication failure
4Resource not found
5Remote/API error
6Internal error

Using in Scripts

#!/bin/bash
set -e

# Test authentication first
if ! raps auth test; then
    echo "Authentication failed!"
    exit 1
fi

# Upload file
raps object upload my-bucket model.rvt

# Check exit code
if [ $? -eq 0 ]; then
    echo "Upload successful"
else
    echo "Upload failed"
    exit 1
fi

Environment Variables

Configure RAPS via environment variables:

# Required
export APS_CLIENT_ID="your_client_id"
export APS_CLIENT_SECRET="your_client_secret"

# Optional
export APS_CALLBACK_URL="http://localhost:8080/callback"  # For 3-legged OAuth
export APS_DA_NICKNAME="your_nickname"                    # For Design Automation
export APS_REGION="US"                                    # Default region (US or EMEA)

Using .env Files

Create a .env file in your working directory:

APS_CLIENT_ID=your_client_id
APS_CLIENT_SECRET=your_client_secret
APS_CALLBACK_URL=http://localhost:8080/callback

RAPS automatically loads .env files.

Profile Management

Manage multiple configurations for different environments:

# Create a profile
raps config profile create production

# Set values
raps config set client_id "prod_client_id"
raps config set client_secret "prod_client_secret"

# Switch profiles
raps config profile use production

# List profiles
raps config profile list

# Use specific profile for a command
raps --profile production bucket list

Scripting Patterns

Upload and Translate

#!/bin/bash
BUCKET="my-project"
FILE="model.rvt"

# Upload
raps object upload "$BUCKET" "$FILE"

# Get URN
URN=$(raps object urn "$BUCKET" "$FILE")

# Start translation and wait
raps translate start "$URN" --format svf2 --wait

# Check result
raps translate manifest "$URN" --output json

Batch Processing

#!/bin/bash
BUCKET="batch-uploads"

# Upload all RVT files
for file in models/*.rvt; do
    echo "Uploading $file..."
    raps object upload "$BUCKET" "$file"
done

# Or use built-in batch upload
raps object upload "$BUCKET" models/*.rvt --batch --parallel 5

Conditional Operations

#!/bin/bash

# Check if bucket exists
if raps bucket get my-bucket > /dev/null 2>&1; then
    echo "Bucket exists"
else
    echo "Creating bucket..."
    raps bucket create my-bucket --retention persistent
fi

Shell Completions

Enable auto-completion in your shell:

Bash

# Add to ~/.bashrc
eval "$(raps completions bash)"

Zsh

# Add to ~/.zshrc
eval "$(raps completions zsh)"

Fish

raps completions fish > ~/.config/fish/completions/raps.fish

PowerShell

# Add to $PROFILE
raps completions powershell | Out-String | Invoke-Expression

Best Practices

1. Use JSON Output for Parsing

# Good: Parse structured data
raps bucket list --output json | jq '.[] | .bucketKey'

# Avoid: Parsing table output
raps bucket list | grep my-bucket  # Fragile!

2. Check Exit Codes

# Good: Check for errors
if raps auth test; then
    echo "Authenticated"
fi

# Good: Fail fast
set -e
raps bucket create my-bucket

3. Use —quiet for Scripting

# Good: Clean output
URN=$(raps object urn my-bucket file.rvt --quiet)

# Avoid: Parsing progress messages
URN=$(raps object urn my-bucket file.rvt 2>/dev/null)

4. Use Profiles for Environments

# Good: Named profiles
raps --profile production bucket list
raps --profile staging bucket list

# Avoid: Changing env vars frequently
export APS_CLIENT_ID="..."  # Error-prone!