-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: make API composable rather than configurable, make separate…
… bin for configurable execution
- Loading branch information
Showing
4 changed files
with
107 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use prepyrus::{utils::VerifiedConfig, Prepyrus}; | ||
|
||
fn main() { | ||
let args: Vec<String> = std::env::args().collect(); | ||
|
||
let VerifiedConfig { | ||
bib_file, | ||
target_path, | ||
mode, | ||
} = Prepyrus::verify_config(&args); | ||
|
||
let all_entries = Prepyrus::get_all_bib_entries(&bib_file).unwrap(); | ||
let mdx_paths = Prepyrus::get_mdx_paths(&target_path).unwrap(); | ||
|
||
// Phase 1: Verify MDX files | ||
let articles_file_data = Prepyrus::verify(mdx_paths, &all_entries).unwrap(); | ||
|
||
// Phase 2: Process MDX files (requires mode to be set to "process") | ||
if mode == "process" { | ||
Prepyrus::process(articles_file_data); | ||
} | ||
|
||
println!("===Prepyrus completed successfully!"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,47 @@ | ||
use prepyrus::run_prepyrus; | ||
use prepyrus::{utils::VerifiedConfig, Prepyrus}; | ||
|
||
#[test] | ||
fn run_verify_with_directory() { | ||
let result = run_prepyrus("tests/mocks/test.bib", "tests/mocks/data", "verify"); | ||
println!("{:?}", result); | ||
assert!(result.is_ok()); | ||
let args = vec![ | ||
"tests/mocks/test.bib".to_string(), | ||
"tests/mocks/data".to_string(), | ||
"verify".to_string(), | ||
]; | ||
let VerifiedConfig { | ||
bib_file, | ||
target_path, | ||
mode, | ||
} = Prepyrus::verify_config(&args); | ||
|
||
let all_entries = Prepyrus::get_all_bib_entries(&bib_file).unwrap(); | ||
let mdx_paths = Prepyrus::get_mdx_paths(&target_path).unwrap(); | ||
let articles_file_data = Prepyrus::verify(mdx_paths, &all_entries).unwrap(); | ||
|
||
println!("{:?}", articles_file_data); | ||
assert!(mode == "verify"); | ||
assert!(articles_file_data.len() > 1); | ||
assert!(!articles_file_data.is_empty()); | ||
} | ||
|
||
#[test] | ||
fn run_verify_with_single_file() { | ||
let result = run_prepyrus( | ||
"tests/mocks/test.bib", | ||
"tests/mocks/data/science-of-logic-introduction.mdx", | ||
"verify", | ||
); | ||
println!("{:?}", result); | ||
assert!(result.is_ok()); | ||
let args = vec![ | ||
"tests/mocks/test.bib".to_string(), | ||
"tests/mocks/data/science-of-logic-introduction.mdx".to_string(), | ||
"verify".to_string(), | ||
]; | ||
let VerifiedConfig { | ||
bib_file, | ||
target_path, | ||
mode, | ||
} = Prepyrus::verify_config(&args); | ||
|
||
let all_entries = Prepyrus::get_all_bib_entries(&bib_file).unwrap(); | ||
let mdx_paths = Prepyrus::get_mdx_paths(&target_path).unwrap(); | ||
let articles_file_data = Prepyrus::verify(mdx_paths, &all_entries).unwrap(); | ||
|
||
println!("{:?}", articles_file_data); | ||
assert!(mode == "verify"); | ||
assert!(articles_file_data.len() == 1); | ||
assert!(!articles_file_data.is_empty()); | ||
} |