aboutsummaryrefslogtreecommitdiff
path: root/tools/src/bin/create_item.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tools/src/bin/create_item.rs')
-rw-r--r--tools/src/bin/create_item.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/src/bin/create_item.rs b/tools/src/bin/create_item.rs
new file mode 100644
index 0000000..7628f95
--- /dev/null
+++ b/tools/src/bin/create_item.rs
@@ -0,0 +1,32 @@
+use std::{fs::File, io::Write, path::PathBuf};
+
+use clap::Parser;
+use jellycommon::ItemInfo;
+
+#[derive(Parser)]
+struct Args {
+ #[clap(short = 'I', long)]
+ item: PathBuf,
+ #[clap(short = 'd', long)]
+ dry: bool,
+ #[clap(short, long)]
+ title: String,
+}
+
+fn main() -> anyhow::Result<()> {
+ let args = Args::parse();
+
+ let iteminfo = ItemInfo {
+ title: args.title,
+ tracks: Default::default(),
+ };
+
+ let k = serde_json::to_string_pretty(&iteminfo)?;
+ if args.dry {
+ println!("{k}")
+ } else {
+ let mut f = File::create(args.item)?;
+ f.write_all(k.as_bytes())?;
+ }
+ Ok(())
+}