Skip to content

Commit

Permalink
Add tally formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
bim9262 committed Sep 5, 2024
1 parent 433d2e0 commit 41257f9
Show file tree
Hide file tree
Showing 3 changed files with 591 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@
//! `max_value` | which value is treated as "full". For example, for battery level `100` is full. | `100`
//! `vertical` or `v` | whether to render the bar vertically or not | `false`
//!
//! ## `tally` - Display numbers as tally marks
//!
//! Argument | Description |Default value
//! ---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------
//! `style` or `s` | One of [`chinese_counting_rods`/`ccr`](https://en.wikipedia.org/wiki/Counting_rods), [`chinese_tally`/`ct`, `western_tally`/`wt`, `western_tally_ungrouped`/`wtu`](https://en.wikipedia.org/wiki/Tally_marks) | western_tally
//!
//! ## `pango-str` - Just display the text without pango markup escaping
//!
//! No arguments.
Expand Down
3 changes: 3 additions & 0 deletions src/formatting/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ macro_rules! new_fmt {

mod bar;
pub use bar::BarFormatter;
mod tally;
pub use tally::TallyFormatter;
mod datetime;
pub use datetime::{DatetimeFormatter, DEFAULT_DATETIME_FORMATTER};
mod eng;
Expand All @@ -51,6 +53,7 @@ pub fn new_formatter(name: &str, args: &[Arg]) -> Result<Box<dyn Formatter>> {
"eng" => Ok(Box::new(EngFormatter::from_args(args)?)),
"pango-str" => Ok(Box::new(PangoStrFormatter::from_args(args)?)),
"str" => Ok(Box::new(StrFormatter::from_args(args)?)),
"tally" => Ok(Box::new(TallyFormatter::from_args(args)?)),
_ => Err(Error::new(format!("Unknown formatter: '{name}'"))),
}
}
Loading

0 comments on commit 41257f9

Please sign in to comment.