Skip to content

Commit

Permalink
Add tally formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
bim9262 committed Mar 31, 2024
1 parent 11e7be0 commit 796e5dd
Show file tree
Hide file tree
Showing 3 changed files with 592 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 @@ -62,6 +62,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](https://en.wikipedia.org/wiki/Counting_rods), [chinese_tally, western_tally, western_tally_ungrouped](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 @@ -11,6 +11,8 @@ use crate::errors::*;

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 @@ -37,6 +39,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 796e5dd

Please sign in to comment.