Skip to content

Commit 59751fc

Browse files
committed
Allow user to provide custom paths to config files
1 parent dd1ea4e commit 59751fc

File tree

7 files changed

+279
-8
lines changed

7 files changed

+279
-8
lines changed

Cargo.lock

Lines changed: 253 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ video-rs = { version = "0.4", features = ["ndarray"] }
1616
ffmpeg-next = "6.0.0"
1717
ndarray = "0.15.6"
1818
fast_image_resize = "2.7.3"
19+
clap = { version = "4.3.5", features = [ "derive" ] }

output/.gitkeep

Whitespace-only changes.

src/data/cli.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
use clap::Parser;
2+
3+
/// Generate a video based on the waveforms of multiple audio tracks
4+
#[derive(Parser, Debug)]
5+
#[command(author, version, about, long_about = None)]
6+
pub struct Args {
7+
/// JSON config file for all the tracks, colours, and audio files
8+
#[arg(short, long, default_value_t = String::from("./song.json"))]
9+
pub song: String,
10+
11+
/// JSON config file for the size and scaling for the output video file
12+
#[arg(short, long, default_value_t = String::from("./window.json"))]
13+
pub window: String,
14+
}

src/data/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
pub mod cli;
12
pub mod song;
23
pub mod track;

src/data/song.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ pub struct Window {
148148
}
149149

150150
impl Window {
151-
pub fn load_from_file() -> Self {
152-
let file = File::open("./song/window.json");
151+
pub fn load_from_file(window_path: &str) -> Self {
152+
let file = File::open(window_path);
153153
if file.is_err() {
154154
panic!("Could not open window.json");
155155
}
@@ -180,8 +180,8 @@ pub struct Song {
180180
}
181181

182182
impl Song {
183-
pub fn load_from_file() -> Self {
184-
let file = File::open("./song/song.json");
183+
pub fn load_from_file(song_path: &str) -> Self {
184+
let file = File::open(song_path);
185185
if file.is_err() {
186186
panic!("Could not open song.json");
187187
}

0 commit comments

Comments
 (0)