use clap::Parser;
use clap::Subcommand;
use clap::ValueEnum;
#[derive(Parser, Debug)]
#[command(
name = "steamroom",
about = "Steam depot downloader",
after_help = "Set DD_COMPAT=1 for flat-argument compatibility with the original DepotDownloader."
)]
pub struct Cli {
#[command(subcommand)]
pub command: Command,
#[command(flatten)]
pub auth: AuthOptions,
#[arg(long)]
pub debug: bool,
#[arg(long)]
pub raw_errors: bool,
#[arg(long)]
pub cell_id: Option<u32>,
#[arg(long)]
pub capture: Option<std::path::PathBuf>,
#[arg(long)]
pub no_progress: bool,
#[arg(short, long)]
pub quiet: bool,
}
#[derive(Parser, Debug)]
#[command(name = "steamroom", about = "Steam depot downloader (DD_COMPAT mode)")]
pub struct CompatCli {
#[arg(long = "app")]
pub app_id: Option<u32>,
#[arg(long = "depot")]
pub depot_id: Option<u32>,
#[arg(long = "manifest")]
pub manifest_id: Option<u64>,
#[arg(long = "username")]
pub username: Option<String>,
#[arg(long = "password")]
pub password: Option<String>,
#[arg(long = "dir")]
pub output: Option<std::path::PathBuf>,
#[arg(long = "branch")]
pub branch: Option<String>,
#[arg(long = "betapassword")]
pub beta_password: Option<String>,
#[arg(long)]
pub qr: bool,
#[arg(long = "remember-password")]
pub remember_password: bool,
#[arg(long = "filelist")]
pub filelist: Option<std::path::PathBuf>,
#[arg(long = "regex")]
pub file_regex: Option<String>,
#[arg(long = "validate")]
pub verify: bool,
#[arg(long)]
pub os: Option<String>,
#[arg(long)]
pub arch: Option<String>,
#[arg(long)]
pub language: Option<String>,
#[arg(long = "max-downloads")]
pub max_downloads: Option<usize>,
#[arg(long = "cellid")]
pub cell_id: Option<u32>,
#[arg(long)]
pub debug: bool,
}
impl CompatCli {
pub fn into_cli(self) -> Cli {
let app = self.app_id.unwrap_or(0);
Cli {
command: Command::Download(DownloadArgs {
app,
depot: self.depot_id,
manifest: self.manifest_id,
filelist: self.filelist,
file_regex: self.file_regex,
output: self.output,
verify: self.verify,
os: self.os,
arch: self.arch,
language: self.language,
login_id: None,
all_platforms: false,
all_architectures: false,
all_languages: false,
lancache: false,
max_downloads: self.max_downloads,
branch: self.branch,
branch_password: self.beta_password,
capture: None,
bytes: false,
}),
auth: AuthOptions {
username: self.username,
password: self.password,
qr: self.qr,
remember_password: self.remember_password,
device_name: None,
},
debug: self.debug,
raw_errors: false,
cell_id: self.cell_id,
capture: None,
no_progress: false,
quiet: false,
}
}
}
#[derive(Parser, Debug)]
pub struct AuthOptions {
#[arg(short, long, env = "STEAM_USER")]
pub username: Option<String>,
#[arg(short, long, env = "STEAM_PASS")]
pub password: Option<String>,
#[arg(long)]
pub qr: bool,
#[arg(long)]
pub remember_password: bool,
#[arg(long, env = "DD_DEVICE_NAME")]
pub device_name: Option<String>,
}
#[derive(Subcommand, Debug)]
pub enum Command {
Download(DownloadArgs),
Files(FilesArgs),
Info(InfoArgs),
Manifests(ManifestsArgs),
Workshop(WorkshopArgs),
}
#[derive(Parser, Debug)]
pub struct DownloadArgs {
#[arg(long)]
pub app: u32,
#[arg(long)]
pub depot: Option<u32>,
#[arg(long)]
pub manifest: Option<u64>,
#[arg(long)]
pub filelist: Option<std::path::PathBuf>,
#[arg(long)]
pub file_regex: Option<String>,
#[arg(long, short)]
pub output: Option<std::path::PathBuf>,
#[arg(long)]
pub verify: bool,
#[arg(long)]
pub os: Option<String>,
#[arg(long)]
pub arch: Option<String>,
#[arg(long)]
pub language: Option<String>,
#[arg(long)]
pub login_id: Option<u32>,
#[arg(long)]
pub all_platforms: bool,
#[arg(long)]
pub all_architectures: bool,
#[arg(long)]
pub all_languages: bool,
#[arg(long)]
pub lancache: bool,
#[arg(long)]
pub max_downloads: Option<usize>,
#[arg(long)]
pub branch: Option<String>,
#[arg(long)]
pub branch_password: Option<String>,
#[arg(long)]
pub capture: Option<std::path::PathBuf>,
#[arg(long)]
pub bytes: bool,
}
#[derive(Parser, Debug)]
pub struct FilesArgs {
#[arg(long)]
pub app: u32,
#[arg(long)]
pub depot: Option<u32>,
#[arg(long)]
pub manifest: Option<u64>,
#[arg(long)]
pub branch: Option<String>,
#[arg(long)]
pub branch_password: Option<String>,
#[arg(long)]
pub os: Option<String>,
#[arg(long, value_enum)]
pub format: Option<OutputFormat>,
#[arg(long)]
pub raw: bool,
#[arg(long)]
pub bytes: bool,
}
#[derive(Parser, Debug)]
pub struct InfoArgs {
#[arg(long)]
pub app: u32,
#[arg(long, value_enum)]
pub format: Option<OutputFormat>,
#[arg(long)]
pub os: Option<String>,
#[arg(long)]
pub show_all: bool,
}
#[derive(Parser, Debug)]
pub struct ManifestsArgs {
#[arg(long)]
pub app: u32,
#[arg(long)]
pub branch: Option<String>,
#[arg(long)]
pub branch_password: Option<String>,
#[arg(long, value_enum)]
pub format: Option<OutputFormat>,
}
#[derive(Parser, Debug)]
pub struct WorkshopArgs {
#[arg(long)]
pub app: u32,
#[arg(long)]
pub item: u64,
#[arg(long, short)]
pub output: Option<std::path::PathBuf>,
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, ValueEnum)]
pub enum OutputFormat {
Table,
Json,
Plain,
}