feat(yarr): restructure into workspace with separate API and CLI crates
Some checks failed
build / checks-matrix (push) Has been cancelled
build / checks-build (push) Has been cancelled
build / codecov (push) Has been cancelled
docs / docs (push) Has been cancelled

This commit is contained in:
uttarayan21
2025-10-08 17:02:34 +05:30
parent e9ecd2a295
commit 03fd2de38f
17 changed files with 803 additions and 148 deletions

View File

@@ -1,93 +0,0 @@
use clap::{Args, Parser, Subcommand};
use std::path::PathBuf;
#[derive(Debug, Parser)]
#[command(name = "yarr")]
#[command(about = "A TUI for managing Sonarr")]
#[command(version)]
pub struct Cli {
/// Path to config file
#[arg(short, long, global = true)]
pub config: Option<PathBuf>,
/// Sonarr URL (overrides config file)
#[arg(long, global = true, env = "YARR_SONARR_URL")]
pub sonarr_url: Option<String>,
/// Sonarr API key (overrides config file)
#[arg(long, global = true, env = "YARR_SONARR_API_KEY")]
pub sonarr_api_key: Option<String>,
#[command(subcommand)]
pub command: Option<Commands>,
}
#[derive(Debug, Subcommand)]
pub enum Commands {
/// Add a new series
Add(AddArgs),
/// List series
List(ListArgs),
/// Start the TUI interface (default)
Tui,
/// Generate shell completions
Completions {
/// The shell to generate completions for
#[arg(value_enum)]
shell: clap_complete::Shell,
},
/// Configuration management
Config(ConfigArgs),
}
#[derive(Debug, Args)]
pub struct AddArgs {
/// Name of the series to add
#[arg(short, long)]
pub name: String,
}
#[derive(Debug, Args)]
pub struct ListArgs {
/// Show only monitored series
#[arg(short, long)]
pub monitored: bool,
}
#[derive(Debug, Args)]
pub struct ConfigArgs {
#[command(subcommand)]
pub action: ConfigAction,
}
#[derive(Debug, Subcommand)]
pub enum ConfigAction {
/// Show current configuration
Show,
/// Create a sample config file
Init {
/// Path where to create the config file
#[arg(short, long)]
path: Option<PathBuf>,
},
/// Show possible config file locations
Paths,
}
impl Cli {
pub fn generate_completions(shell: clap_complete::Shell) {
let mut command = <Cli as clap::CommandFactory>::command();
clap_complete::generate(
shell,
&mut command,
env!("CARGO_BIN_NAME"),
&mut std::io::stdout(),
);
}
}