use clap::{ArgGroup, Subcommand};
use std::path::PathBuf;
#[derive(Debug, Subcommand)]
pub enum ModuleCommands {
#[command(visible_alias = "ls")]
List,
#[command(group(ArgGroup::new("identifier").required(true).args(["uid", "name"])))]
Get {
#[arg(conflicts_with = "name")]
uid: Option<String>,
#[arg(long, conflicts_with = "uid")]
name: Option<String>,
},
Upload {
#[arg(long)]
file: String,
},
#[command(visible_alias = "rm")]
Delete {
uid: String,
#[arg(long, short)]
force: bool,
},
#[command(
name = "config-bdb",
after_help = "EXAMPLES:
# Configure module with name
redisctl enterprise module config-bdb 1 --module-name ReJSON --module-args '--maxarrsize 1000'
# Using JSON for full configuration
redisctl enterprise module config-bdb 1 --data @module-config.json"
)]
ConfigBdb {
bdb_uid: u32,
#[arg(long)]
module_name: Option<String>,
#[arg(long)]
module_args: Option<String>,
#[arg(long, value_name = "FILE|JSON")]
data: Option<String>,
},
#[command(after_help = "EXAMPLES:
# Validate a module.json file
redisctl enterprise module validate ./module.json
# Validate with strict mode (all recommended fields required)
redisctl enterprise module validate ./module.json --strict")]
Validate {
file: PathBuf,
#[arg(long)]
strict: bool,
},
#[command(after_help = "EXAMPLES:
# Inspect a module package
redisctl enterprise module inspect ./redis-jmespath.Linux-x86_64.0.3.0.zip
# Show full metadata including all commands
redisctl enterprise module inspect ./module.zip --full")]
Inspect {
file: PathBuf,
#[arg(long)]
full: bool,
},
#[command(after_help = "EXAMPLES:
# Package a module
redisctl enterprise module package \\
--module ./libredis_jmespath.so \\
--metadata ./module.json \\
--out ./dist/redis-jmespath.Linux-x86_64.0.3.0.zip
# Package with validation
redisctl enterprise module package \\
--module ./module.so \\
--metadata ./module.json \\
--out ./package.zip \\
--validate")]
Package {
#[arg(long)]
module: PathBuf,
#[arg(long)]
metadata: PathBuf,
#[arg(long = "out")]
output_path: PathBuf,
#[arg(long)]
validate: bool,
},
}