Initial code commit
CI / test (push) Successful in 5m7s

This commit is contained in:
IxianPixel committed 2026-11-05 14:19:37 +00:00
1 parent f47217d5a3
commit 8ceb3c8be8
60 files changed
+10884

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
[package]
name = "jellymove"
version.workspace = true
edition.workspace = true
license.workspace = true
rust-version.workspace = true
[dependencies]
anyhow = "1.0.104"
clap = { version = "4.6.7", features = ["derive", "env"] }
figment = { version = "0.10.19", features = ["toml", "env"] }
jm-core = { version = "0.1.0", path = "../jm-core" }
jm-server = { version = "0.1.0", path = "../jm-server" }
serde = { version = "1.0.229", features = ["derive"] }
serde_json = "1.0.154"
tokio = { version = "1.54.1", features = ["full"] }
tracing = "0.1.44"
tracing-subscriber = { version = "0.3.23", features = ["env-filter", "json"] }
+77
View File
@@ -0,0 +1,77 @@
use std::path::PathBuf;
use anyhow::Context;
use clap::{Parser, Subcommand};
use figment::Figment;
use figment::providers::{Env, Format, Toml};
use tracing_subscriber::EnvFilter;
const EXAMPLE_CONFIG: &str = include_str!("../../../config.example.toml");
#[derive(Parser)]
#[command(version, about = "Move media between two Jellyfin servers")]
struct Cli {
/// Config file (TOML). Values can be overridden with JELLYMOVE_* env vars.
#[arg(
short,
long,
env = "JELLYMOVE_CONFIG",
default_value = "jellymove.toml",
global = true
)]
config: PathBuf,
/// Log as JSON lines (for log shippers).
#[arg(long, env = "JELLYMOVE_LOG_JSON", global = true)]
log_json: bool,
#[command(subcommand)]
command: Option<Command>,
}
#[derive(Subcommand)]
enum Command {
/// Run the daemon (default).
Run,
/// Load and validate the config, print it with secrets redacted, then exit.
CheckConfig,
/// Print an example config file.
ExampleConfig,
}
fn load(path: &PathBuf) -> anyhow::Result<jm_server::Config> {
let mut fig = Figment::new();
if path.exists() {
fig = fig.merge(Toml::file(path));
} else {
tracing::warn!(path = %path.display(), "config file not found; using environment only");
}
fig.merge(
Env::prefixed("JELLYMOVE_")
.split("__")
.ignore(&["config", "log_json"]),
)
.extract()
.with_context(|| format!("invalid configuration (file: {})", path.display()))
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let cli = Cli::parse();
let filter = EnvFilter::try_from_env("JELLYMOVE_LOG")
.unwrap_or_else(|_| EnvFilter::new("info,tower_http=warn"));
let fmt = tracing_subscriber::fmt().with_env_filter(filter);
if cli.log_json {
fmt.json().init()
} else {
fmt.init()
}
match cli.command.unwrap_or(Command::Run) {
Command::ExampleConfig => print!("{EXAMPLE_CONFIG}"),
Command::CheckConfig => {
let cfg = load(&cli.config)?;
println!("{}", serde_json::to_string_pretty(&cfg.redacted())?);
}
Command::Run => jm_server::run(load(&cli.config)?).await?,
}
Ok(())
}