use pipeless_ai;
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
struct Cli {
#[command(subcommand)]
command: Option<Commands>,
}
#[derive(Subcommand)]
enum AddCommand {
Stream {
#[arg(short, long)]
input_uri: String,
#[arg(short, long)]
output_uri: Option<String>,
#[arg(short, long)]
frame_path: String,
#[arg(short, long)]
restart_policy: Option<String>,
}
}
#[derive(Subcommand)]
enum RemoveCommand {
Stream {
#[arg(long)]
id: String,
}
}
#[derive(Subcommand)]
enum UpdateCommand {
Stream {
#[arg(long)]
id: String,
#[arg(short, long)]
input_uri: Option<String>,
#[arg(short, long)]
output_uri: Option<String>,
#[arg(short, long)]
frame_path: Option<String>,
#[arg(short, long)]
restart_policy: Option<String>,
}
}
#[derive(Subcommand)]
enum ListCommand {
Streams,
}
#[derive(Subcommand)]
enum GenerateCommand {
Stage,
Hook
}
#[derive(Subcommand)]
enum Commands {
Init {
project_name: String,
#[arg(short, long)]
template: Option<String>,
},
Start {
#[clap(short, long, alias = "stages-dir")]
project_dir: String,
#[clap(short, long)]
export_events_redis: bool,
#[clap(short, long, default_value = "240")]
stream_buffer_size: usize,
},
Add {
#[command(subcommand)]
command: Option<AddCommand>,
},
Remove {
#[command(subcommand)]
command: Option<RemoveCommand>,
},
Update {
#[command(subcommand)]
command: Option<UpdateCommand>,
},
List {
#[command(subcommand)]
command: Option<ListCommand>,
},
Generate {
#[command(subcommand)]
command: Option<GenerateCommand>,
}
}
fn main() {
let cli = Cli::parse();
match &cli.command {
Some(Commands::Init { project_name , template}) => pipeless_ai::cli::init::init(&project_name, template),
Some(Commands::Start { project_dir , export_events_redis , stream_buffer_size}) => pipeless_ai::cli::start::start_pipeless_node(&project_dir, *export_events_redis, *stream_buffer_size),
Some(Commands::Add { command }) => {
match &command {
Some(AddCommand::Stream { input_uri, output_uri, frame_path , restart_policy}) => pipeless_ai::cli::streams::add(input_uri, output_uri, frame_path, restart_policy),
None => println!("Use --help to see the complete list of available commands"),
}
},
Some(Commands::Remove { command }) => {
match &command {
Some(RemoveCommand::Stream { id }) => pipeless_ai::cli::streams::remove(id),
None => println!("Use --help to see the complete list of available commands"),
}
},
Some(Commands::Update { command }) => {
match &command {
Some(UpdateCommand::Stream { id, input_uri, output_uri, frame_path , restart_policy}) => pipeless_ai::cli::streams::update(id, input_uri, output_uri, frame_path, restart_policy),
None => println!("Use --help to see the complete list of available commands"),
}
},
Some(Commands::List { command }) => {
match &command {
Some(ListCommand::Streams) => pipeless_ai::cli::streams::list(),
None => println!("Use --help to see the complete list of available commands"),
}
},
Some(Commands::Generate { command }) => {
match &command {
Some(GenerateCommand::Stage) => pipeless_ai::cli::stage::generate_stage(),
Some(GenerateCommand::Hook) => pipeless_ai::cli::hook::generate_hook_wrapper(),
None => println!("Use --help to see the complete list of available commands"),
}
},
None => println!("Use --help to see the complete list of available commands"),
}
}