Skip to content

Commit

Permalink
Merge pull request #574 from googlefonts/otexplorer-help-msg
Browse files Browse the repository at this point in the history
[otexplorer] Improve help message
  • Loading branch information
anthrotype authored Aug 15, 2023
2 parents 137243e + 63e9ac2 commit a8ce698
Showing 1 changed file with 26 additions and 4 deletions.
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

0 comments on commit a8ce698

Please sign in to comment.