aboutsummaryrefslogtreecommitdiff
path: root/tools/src/bin/create_item.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-01-16 10:57:40 +0100
committermetamuffin <metamuffin@disroot.org>2023-01-16 10:57:40 +0100
commit9f9449ddd58eb07d20e14e7a75c7387c9cc17ebe (patch)
tree52e39085589303d3d2e386a3575152fb6594bb61 /tools/src/bin/create_item.rs
parente3f1a8ac9f4c9a015e9eac769fb3262e3bd16bad (diff)
downloadjellything-9f9449ddd58eb07d20e14e7a75c7387c9cc17ebe.tar
jellything-9f9449ddd58eb07d20e14e7a75c7387c9cc17ebe.tar.bz2
jellything-9f9449ddd58eb07d20e14e7a75c7387c9cc17ebe.tar.zst
write more code
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(())
+}