Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[otexplorer] Improve help message #574

Merged
merged 1 commit into from
Aug 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions otexplorer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use print::PrettyPrinter;
use query::Query;

fn main() -> Result<(), Error> {
let args = flags::Args::from_env().map_err(|e| Error(e.to_string()))?;
let args = flags::Otexplorer::from_env_or_exit();
let bytes = std::fs::read(&args.input).unwrap();
let font = FileRef::new(&bytes)
.unwrap()
Expand Down Expand Up @@ -139,7 +139,7 @@ enum TableFilter {
}

impl TableFilter {
fn from_args(args: &flags::Args) -> Result<Self, Error> {
fn from_args(args: &flags::Otexplorer) -> Result<Self, Error> {
if args.tables.is_some() && args.exclude.is_some() {
return Err(Error::new("pass only one of --tables and --exclude"));
}
Expand Down Expand Up @@ -202,8 +202,30 @@ mod flags {
use std::path::PathBuf;

xflags::xflags! {
/// Generate font table representations
cmd args {
/// Explore the contents of binary font files
///
/// otexplorer can print a textual representation of the the tables in
/// a font file, or some subset of those tables.
///
/// In addition to this, the -q option allows the user to provide a query,
/// which can be used to print some particular subtable or value.
///
/// Queries begin with a table tag, and then zero or more path elements,
/// separated by a period ('.'). Path elements can be either the names
/// of fields, or indexes into an array.
///
/// For instance, to print the first subtable of the second lookup in
/// the GPOS table, you can do,
///
/// otexplorer $myfont -q GPOS.lookup_list.lookup_offsets.1.subtable_offsets.0
///
/// Queries are case-insensitive, and fuzzily matched. The following
/// two examples produce identical results to the example above:
///
/// otexplorer $myfont -q GPOS.lookupListOffset.lookupOffsets.1.subtableOffsets.0
/// otexplorer $myfont -q GPOS.look.off.1.off.0

cmd otexplorer {
required input: PathBuf
optional -i, --index index: u32
optional -l, --list
Expand Down