Passa al contenuto principale

πŸ› οΈ CLI Commands Reference

cargo-ferrox provides an interactive command-line interface for scaffolding new projects and generating strongly typed TypeScript API clients for frontend applications.


1. Installation​

To install cargo-ferrox globally via Cargo from crates.io:

cargo install cargo-ferrox

Verify installation:

cargo ferrox --version

2. Commands Overview​

ferrox init​

Scaffolds a new Ferrox enterprise application with interactive prompts for project naming, database selection (SeaORM / MongoDB / Redis), and locale detection.

ferrox init my-enterprise-app

Interactive Options​

πŸš€ Welcome to Ferrox CLI! Let's scaffold your Enterprise App.
Qual Γ¨ il nome del tuo progetto? my-enterprise-app
Quale database desideri utilizzare?
> PostgreSQL (SeaORM)
MongoDB
Redis Only
βœ… Project scaffolded successfully!

ferrox generate​

Triggers the Ferrox Code Factory engine to parse backend Axum controllers and DTOs and generate a strongly typed TypeScript client SDK.

ferrox generate --lang ts --output ./frontend/src/api

Flags​

FlagDefaultDescription
--langtsTarget frontend language (TypeScript)
--output./frontend/src/apiDirectory destination for generated FerroxClient.ts

3. Generated TypeScript Client SDK (FerroxClient.ts)​

ferrox generate creates a clean, zero-dependency fetch wrapper:

// AUTO-GENERATED BY FERROX CODE FACTORY
// DO NOT EDIT MANUALLY

export class FerroxClient {
private baseUrl: string;
private token: string;

constructor(baseUrl: string, token: string) {
this.baseUrl = baseUrl;
this.token = token;
}

private async request<T>(endpoint: string, options: RequestInit): Promise<T> {
const headers = new Headers(options.headers);
headers.set('Authorization', `Bearer ${this.token}`);
headers.set('Content-Type', 'application/json');

const response = await fetch(`${this.baseUrl}${endpoint}`, {
...options,
headers,
});

if (!response.ok) {
throw new Error(`API Error: ${response.statusText}`);
}

return response.json();
}

public async getProfile(): Promise<any> {
return this.request<any>('/profile', { method: 'GET' });
}
}