Skip to content

Commit

Permalink
chore: migrate commands to use dynfmt2
Browse files Browse the repository at this point in the history
  • Loading branch information
jqnatividad committed Jan 8, 2025
1 parent bf8a180 commit 04abcf2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/cmd/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ use censor::{Censor, Sex, Zealous};
use cpc::{eval, units::Unit};
use crc32fast;
use data_encoding::BASE64;
use dynfmt::Format;
use dynfmt2::Format;
use eudex::Hash;
use gender_guesser::Gender;
use indicatif::{ProgressBar, ProgressDrawTarget};
Expand Down Expand Up @@ -643,7 +643,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
record_vec.push(field.to_string());
}
if let Ok(formatted) =
dynfmt::SimpleCurlyFormat.format(&dynfmt_template, record_vec)
dynfmt2::SimpleCurlyFormat.format(&dynfmt_template, record_vec)
{
cell = formatted.to_string();
}
Expand All @@ -664,7 +664,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
record_vec.push(field.to_string());
}
if let Ok(formatted) =
dynfmt::SimpleCurlyFormat.format(&dynfmt_template, record_vec)
dynfmt2::SimpleCurlyFormat.format(&dynfmt_template, record_vec)
{
cell = formatted.to_string();
}
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/applydp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ Common options:

use std::{str::FromStr, sync::OnceLock};

use dynfmt::Format;
use dynfmt2::Format;
use log::debug;
use rayon::{
iter::{IndexedParallelIterator, ParallelIterator},
Expand Down Expand Up @@ -460,7 +460,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
record_vec.push(field.to_string());
}
if let Ok(formatted) =
dynfmt::SimpleCurlyFormat.format(&dynfmt_template, record_vec)
dynfmt2::SimpleCurlyFormat.format(&dynfmt_template, record_vec)
{
cell = formatted.to_string();
}
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ use cached::{
stores::DiskCacheBuilder,
Cached, IOCached, RedisCache, Return, SizedCache,
};
use dynfmt::Format;
use dynfmt2::Format;
use governor::{
clock::DefaultClock,
middleware::NoOpMiddleware,
Expand Down Expand Up @@ -780,7 +780,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
);
}
if let Ok(formatted) =
dynfmt::SimpleCurlyFormat.format(&dynfmt_url_template, &*record_vec)
dynfmt2::SimpleCurlyFormat.format(&dynfmt_url_template, &*record_vec)
{
url = formatted.into_owned();
}
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/geocode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ use std::{

use ahash::RandomState;
use cached::{proc_macro::cached, SizedCache};
use dynfmt::Format;
use dynfmt2::Format;
use geosuggest_core::{
storage::{self, IndexStorage},
CitiesRecord, CountryRecord, Engine,
Expand Down Expand Up @@ -1933,7 +1933,7 @@ fn format_result(
};
}

if let Ok(formatted) = dynfmt::SimpleCurlyFormat.format(formatstr, cityrecord_map) {
if let Ok(formatted) = dynfmt2::SimpleCurlyFormat.format(formatstr, cityrecord_map) {
formatted.to_string()
} else {
INVALID_DYNFMT.to_string()
Expand Down Expand Up @@ -2047,7 +2047,7 @@ fn get_countryinfo(
};
}

if let Ok(formatted) = dynfmt::SimpleCurlyFormat.format(formatstr, countryrecord_map) {
if let Ok(formatted) = dynfmt2::SimpleCurlyFormat.format(formatstr, countryrecord_map) {
Some(formatted.to_string())
} else {
Some(INVALID_DYNFMT.to_string())
Expand Down
10 changes: 5 additions & 5 deletions src/cmd/pseudo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Common options:
"#;

use ahash::AHashMap;
use dynfmt::Format;
use dynfmt2::Format;
use serde::Deserialize;

use crate::{
Expand Down Expand Up @@ -130,7 +130,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
let mut overflowed = false;

if args.flag_formatstr == "{}" {
// we don't need to use dynfmt::SimpleCurlyFormat if the format string is "{}"
// we don't need to use dynfmt2::SimpleCurlyFormat if the format string is "{}"
let mut values_num = ValuesNum::with_capacity(1000);

while rdr.read_record(&mut record)? {
Expand All @@ -152,11 +152,11 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
wtr.write_record(&record)?;
}
} else {
// we need to use dynfmt::SimpleCurlyFormat if the format string is not "{}"
// we need to use dynfmt2::SimpleCurlyFormat if the format string is not "{}"

// first, validate the format string
if !args.flag_formatstr.contains("{}")
|| dynfmt::SimpleCurlyFormat
|| dynfmt2::SimpleCurlyFormat
.format(&args.flag_formatstr, [0])
.is_err()
{
Expand All @@ -175,7 +175,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
let new_value = values.entry(value.clone()).or_insert_with(|| {
curr_counter = counter;
(counter, overflowed) = counter.overflowing_add(increment);
dynfmt::SimpleCurlyFormat
dynfmt2::SimpleCurlyFormat
.format(&args.flag_formatstr, [curr_counter])
.unwrap()
.to_string()
Expand Down

0 comments on commit 04abcf2

Please sign in to comment.