| Crates.io | reinhardt-commands |
| lib.rs | reinhardt-commands |
| version | 0.1.0-alpha.1 |
| created_at | 2026-01-23 10:58:06.2299+00 |
| updated_at | 2026-01-23 10:58:06.2299+00 |
| description | Django-style management command framework for Reinhardt |
| homepage | |
| repository | https://github.com/kent8192/reinhardt-web |
| max_upload_size | |
| id | 2064131 |
| size | 902,445 |
Django-style management command framework for Reinhardt.
reinhardt-commands provides a Django-inspired command-line interface for
managing Reinhardt projects. It includes built-in commands for database
migrations, static file collection, development server, and more.
Add reinhardt to your Cargo.toml:
[dependencies]
reinhardt = { version = "0.1.0-alpha.1", features = ["commands"] }
# Or use a preset:
# reinhardt = { version = "0.1.0-alpha.1", features = ["standard"] } # Recommended
# reinhardt = { version = "0.1.0-alpha.1", features = ["full"] } # All features
Then import command features:
use reinhardt::commands::{Command, CommandRegistry, execute_from_command_line};
Note: Command features are included in the standard and full feature presets.
For creating new projects and apps, use the separate reinhardt-admin-cli
package:
cargo install reinhardt-admin-cli
This installs the reinhardt-admin command:
reinhardt-admin startproject myproject
reinhardt-admin startapp myapp
See reinhardt-admin documentation for more details.
STATIC_ROOTrouters
feature)migrations - Enable migration-related commands (requires
reinhardt-migrations)routers - Enable URL-related commands (requires reinhardt-routers)reinhardt-commands uses the
Tera template engine for rendering project and
app templates during code generation (e.g., startproject and startapp
commands).
Templates use Tera's syntax, which is compatible with Jinja2/Django templates:
// Variable substitution
{{ variable_name }}
{{ camel_case_app_name }}
// Conditional logic (available in Tera, not in old string replacement)
{% if is_mtv %}
pub mod templates;
{% endif %}
// Loops (available in Tera, not in old string replacement)
{% for item in items %}
{{ item }}
{% endfor %}
When rendering templates, the following variables are available:
For startproject:
project_name - The project name (e.g., "my_project")camel_case_project_name - CamelCase version (e.g., "MyProject")secret_key - Generated Django-compatible secret keyreinhardt_version - Current Reinhardt framework versionis_mtv - "true" or "false" flagis_restful - "true" or "false" flagFor startapp:
app_name - The app name (e.g., "users")camel_case_app_name - CamelCase version (e.g., "Users")is_mtv - "true" or "false" flagis_restful - "true" or "false" flagYou can pass custom variables to templates programmatically:
use reinhardt::commands::TemplateContext;
let mut context = TemplateContext::new();
context.insert("project_name", "my_project");
context.insert("version", "1.0.0");
context.insert("features", vec!["auth", "admin"]); // Any Serialize type
manage.rs)Create a manage.rs in your project's src/bin/ directory:
use clap::{Parser, Subcommand};
use reinhardt::commands::{
CheckCommand, CommandContext, MakeMigrationsCommand,
MigrateCommand, RunServerCommand,
};
#[derive(Parser)]
#[command(name = "manage")]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Makemigrations {
#[arg(value_name = "APP_LABEL")]
app_labels: Vec<String>,
#[arg(long)]
dry_run: bool,
},
Migrate {
#[arg(value_name = "APP_LABEL")]
app_label: Option<String>,
},
// ... other commands
}
#[tokio::main]
async fn main() {
// Parse CLI and execute commands
// See templates/project/src/bin/manage.rs for complete example
}
Then run commands with:
cargo run --bin manage makemigrations
cargo run --bin manage migrate
cargo run --bin manage runserver
| Django | Reinhardt |
|---|---|
python manage.py makemigrations |
cargo run --bin manage makemigrations |
python manage.py migrate |
cargo run --bin manage migrate |
python manage.py runserver |
cargo run --bin manage runserver |
python manage.py shell |
cargo run --bin manage shell |
python manage.py check |
cargo run --bin manage check |
python manage.py collectstatic |
cargo run --bin manage collectstatic |
django-admin startproject |
reinhardt-admin startproject |
django-admin startapp |
reinhardt-admin startapp |
Create custom commands by implementing the BaseCommand trait:
use reinhardt::commands::{BaseCommand, CommandContext, CommandResult};
use async_trait::async_trait;
struct MyCommand;
#[async_trait]
impl BaseCommand for MyCommand {
fn name(&self) -> &str {
"mycommand"
}
fn description(&self) -> &str {
"My custom command"
}
async fn execute(&self, ctx: &CommandContext) -> CommandResult<()> {
ctx.info("Executing my command!");
Ok(())
}
}
Register your command in manage.rs:
use reinhardt::commands::CommandRegistry;
let mut registry = CommandRegistry::new();
registry.register(Box::new(MyCommand));
The plugin command system integrates with reinhardt-dentdelion to provide CLI commands for managing plugins:
| Command | Description |
|---|---|
plugin list |
List all installed plugins |
plugin info <name> |
Show detailed information about a plugin |
plugin install <name> |
Install a plugin from crates.io |
plugin remove <name> |
Remove an installed plugin |
plugin enable <name> |
Enable a disabled plugin |
plugin disable <name> |
Disable an active plugin |
plugin search <query> |
Search for plugins on crates.io |
plugin update <name> |
Update a plugin to the latest version |
# List all plugins
reinhardt plugin list
# Install a plugin from crates.io
reinhardt plugin install my-awesome-plugin
# Show plugin details
reinhardt plugin info my-awesome-plugin
# Enable/disable plugins
reinhardt plugin enable my-awesome-plugin
reinhardt plugin disable my-awesome-plugin
# Search for plugins
reinhardt plugin search authentication
# Update a plugin
reinhardt plugin update my-awesome-plugin
Plugin commands automatically update your project's dentdelion.toml manifest:
[plugins]
my-awesome-plugin = { version = "1.0.0", enabled = true }
auth-plugin = { version = "2.1.0", enabled = false }
Plugin commands are implemented in src/plugin_commands.rs and use the reinhardt-dentdelion crate for plugin management:
use reinhardt::commands::BaseCommand;
use reinhardt::dentdelion::{PluginInstaller, CratesIoClient};
#[async_trait]
impl BaseCommand for PluginInstallCommand {
fn name(&self) -> &str {
"plugin install"
}
async fn execute(&self, ctx: &CommandContext) -> CommandResult<()> {
let installer = PluginInstaller::new()?;
installer.install(&plugin_name, None).await?;
Ok(())
}
}
reinhardt-commands includes project and app templates:
reinhardt-admin startproject myproject --template-type restful
reinhardt-admin startapp myapp --template-type restful
Templates are embedded in the binary using rust-embed for fast,
dependency-free project generation.
reinhardt-commands is designed to be:
Licensed under either of:
at your option.