/*
SPDX-License-Identifier: GPL-3.0-or-later
Copyright © 2024 Mike Robeson [dijksterhuis]
*/
mod helpers;
use helpers::*;

use ot_tools_io::{ArrangementFile, BankFile, MarkersFile, OctatrackFileIO, ProjectFile};
use std::path::PathBuf;

fn bank_fname_from_id(id: usize) -> String {
    format!["bank{id:0>2}.work"].to_string()
}

fn arr_fname_from_id(id: usize) -> String {
    format!["arr{id:0>2}.work"].to_string()
}

fn main() -> RBoxErr<()> {
    let project_dirpath = PathBuf::from("example-new-project");

    std::fs::create_dir_all(&project_dirpath)?;

    let proj_fpath = project_dirpath.join("project.work");
    ProjectFile::default().to_data_file(&proj_fpath)?;

    let markers_fpath = project_dirpath.join("markers.work");
    MarkersFile::default().to_data_file(&markers_fpath)?;

    for i in 1..=16 {
        let bank_fpath = project_dirpath.join(bank_fname_from_id(i));
        BankFile::default().to_data_file(&bank_fpath)?;
    }

    for i in 1..=8 {
        let arr_fpath = project_dirpath.join(arr_fname_from_id(i));
        ArrangementFile::default().to_data_file(&arr_fpath)?;
    }

    println!("New project created: {project_dirpath:?}");
    Ok(())
}
