logseq-export/src/main.rs

41 lines
1 KiB
Rust

use clap::Parser;
use logseq_export::process_metadata;
use logseq_export::{copy_files, process_files};
use std::fs;
use std::io;
use std::path::Path;
#[derive(Parser, Debug)]
#[command(version)]
struct Args {
#[arg(short, long)]
input: String,
#[arg(short, long)]
output: String,
}
fn main() -> io::Result<()> {
let args = Args::parse();
let input_path = Path::new(&args.input);
let output_path = Path::new(&args.output);
input_path.join("logseq").try_exists()?;
let input_assets = input_path.join("assets");
let output_assets = output_path.join("assets");
fs::create_dir_all(&output_assets)?;
copy_files(&input_assets, &output_assets)?;
let input_journals = input_path.join("journals");
let input_pages = input_path.join("pages");
process_files(&input_journals, &output_path, true)?;
process_files(&input_pages, &output_path, false)?;
let metadata = fs::read_to_string(input_path.join("logseq/pages-metadata.edn"))?;
process_metadata(&metadata, &output_path)?;
Ok(())
}