-
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.
- Loading branch information
1 parent
388d7b9
commit ef0ddd4
Showing
5 changed files
with
721 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,15 @@ | ||
[package] | ||
name = "theme-parser" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
anyhow = "1.0.79" | ||
clap = { version = "4.4.18", features = ["derive"] } | ||
nom = "7.1.3" | ||
thiserror = "1.0.56" | ||
|
||
[dev-dependencies] | ||
test-case = "3.3.1" |
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,35 @@ | ||
//! A minimal font.pf2 parser impl that prints the parsed Rust struct | ||
use std::fs::read; | ||
|
||
use args::Args; | ||
use clap::Parser as _; | ||
use theme_parser::pff2::Parser; | ||
|
||
mod args { | ||
use std::path::PathBuf; | ||
|
||
use clap::Parser; | ||
|
||
#[derive(Parser)] | ||
pub struct Args { | ||
#[clap(long, short = 'f')] | ||
pub font_file: PathBuf, | ||
} | ||
} | ||
|
||
fn main() -> anyhow::Result<()> { | ||
let args = Args::parse(); | ||
|
||
let data = read(args.font_file)?; | ||
let font = Parser::parse(&data).unwrap().validate(); | ||
|
||
let print = format!("{font:#?}") | ||
.split("\n") | ||
.take(100) | ||
.fold(String::new(), |print, line| print + line + "\n"); | ||
|
||
println!("{print}"); | ||
|
||
Ok(()) | ||
} |
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,5 +1,12 @@ | ||
use std::rc::Rc; | ||
|
||
#[cfg(test)] | ||
#[macro_use] | ||
extern crate test_case; | ||
|
||
extern crate thiserror; | ||
|
||
pub mod pff2; | ||
pub mod theme_txt; | ||
|
||
pub type OwnedSlice<T> = Rc<T>; |
Oops, something went wrong.