Skip to content

Commit 50f6a4f

Browse files
maxwelljhuangkalwalt
authored andcommitted
fix(examples): use arlog_rel! for help banner and prompt UI per review
Converts the 16 help-banner eprintln! sites in generate_patt.rs and the 5 surrounding eprintln! calls in nft_marker_gen.rs y/N prompt block to arlog_rel!, which routes through the arlog system without applying a severity prefix. This was the correct macro for help text and prompt UI; my original PR kept these as eprintln! because I missed arlog_rel! in the arlog macro family. eprint!("Continue anyway? [y/N] ") at nft_marker_gen.rs:152 left as-is per maintainer guidance -- interactive prompts need synchronous stderr behavior that a log facade may not guarantee. Empty blank-line spacers (formerly empty eprintln!()) use arlog_rel!("") because bare arlog_rel!() does not compile -- the macro accepts $($arg:tt)* but forwards to log::log! which requires $($arg:tt)+. Observable output is identical (the arlog::rel formatter is prefix-free, so an empty message renders as a bare newline). Verified generate_patt --help output is plain text with zero [info]/[warning]/[error] prefixes. Addresses review comments on PR 3 / #90.
1 parent 02c291e commit 50f6a4f

2 files changed

Lines changed: 24 additions & 22 deletions

File tree

crates/core/examples/generate_patt.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::path::Path;
1010
use std::str::FromStr;
1111
use webarkitlib_rs::pattern::{ar_patt_get_image2, ar_patt_save};
1212
use webarkitlib_rs::types::{ARMarkerInfo, ARParam, ARParamLT, ARParamLTf, ARPixelFormat};
13-
use webarkitlib_rs::{arlog_e, arlog_i, arlog_w};
13+
use webarkitlib_rs::{arlog_e, arlog_i, arlog_rel, arlog_w};
1414

1515
/*
1616
English documentation / notes for this example
@@ -75,24 +75,24 @@ use webarkitlib_rs::{arlog_e, arlog_i, arlog_w};
7575
*/
7676

7777
fn print_help_and_exit() {
78-
eprintln!("generate_patt example — usage:");
79-
eprintln!(" --input PATH input image (default: examples/Data/HIRO-test.jpg)");
80-
eprintln!(" --out PATH output .patt path (default: ./crates/core/examples/Data/generated.patt)");
81-
eprintln!(" --camera PATH camera_para.dat path to build ARParamLT (optional)");
82-
eprintln!(" --border N add black border of N pixels around input (default: 0)");
83-
eprintln!(" --patt-size N pattern size in pixels (default: 16)");
84-
eprintln!(
78+
arlog_rel!("generate_patt example — usage:");
79+
arlog_rel!(" --input PATH input image (default: examples/Data/HIRO-test.jpg)");
80+
arlog_rel!(" --out PATH output .patt path (default: ./crates/core/examples/Data/generated.patt)");
81+
arlog_rel!(" --camera PATH camera_para.dat path to build ARParamLT (optional)");
82+
arlog_rel!(" --border N add black border of N pixels around input (default: 0)");
83+
arlog_rel!(" --patt-size N pattern size in pixels (default: 16)");
84+
arlog_rel!(
8585
" --sample-factor N sample factor multiplier passed to extraction (default: 4)"
8686
);
87-
eprintln!(" --flip-v flip input image vertically before processing");
88-
eprintln!(" --channel-order rgb|bgr interpret input buffer as rgb or bgr (default: rgb)");
89-
eprintln!(" --with-border indicate the INPUT IMAGE ALREADY CONTAINS THE MARKER BORDER (no auto-add)");
90-
eprintln!(" --patt-ratio F pattern ratio (pattern/(pattern+2*border)), default 0.5");
91-
eprintln!(" --batch run automatic experiments and write CSV report");
92-
eprintln!(" --quiet reduce printed output");
93-
eprintln!(" --verbose print verbose diagnostic info (full_side, min_dim) when border is auto-computed");
94-
eprintln!(" --debug print very verbose intermediate extraction values (threshold, bbox, vertices, params)");
95-
eprintln!(" --help show this help");
87+
arlog_rel!(" --flip-v flip input image vertically before processing");
88+
arlog_rel!(" --channel-order rgb|bgr interpret input buffer as rgb or bgr (default: rgb)");
89+
arlog_rel!(" --with-border indicate the INPUT IMAGE ALREADY CONTAINS THE MARKER BORDER (no auto-add)");
90+
arlog_rel!(" --patt-ratio F pattern ratio (pattern/(pattern+2*border)), default 0.5");
91+
arlog_rel!(" --batch run automatic experiments and write CSV report");
92+
arlog_rel!(" --quiet reduce printed output");
93+
arlog_rel!(" --verbose print verbose diagnostic info (full_side, min_dim) when border is auto-computed");
94+
arlog_rel!(" --debug print very verbose intermediate extraction values (threshold, bbox, vertices, params)");
95+
arlog_rel!(" --help show this help");
9696
std::process::exit(0);
9797
}
9898

crates/core/examples/nft_marker_gen.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ use clap::Parser;
6464
use std::path::Path;
6565
use std::time::Instant;
6666
use webarkitlib_rs::ar2::{ar2_gen_feature_map, ar2_gen_image_set};
67+
#[cfg(not(feature = "ffi-backend"))]
68+
use webarkitlib_rs::arlog_rel;
6769
#[cfg(feature = "ffi-backend")]
6870
use webarkitlib_rs::arlog_w;
6971
use webarkitlib_rs::{arlog_e, arlog_i};
@@ -142,22 +144,22 @@ fn main() {
142144
{
143145
use std::io::Write as _;
144146
if !cli.yes {
145-
eprintln!();
146-
eprintln!(
147+
arlog_rel!("");
148+
arlog_rel!(
147149
"Warning: built without `ffi-backend` feature — .fset3 will NOT be generated."
148150
);
149-
eprintln!("An NFT marker without .fset3 cannot be used for initialization/detection.");
151+
arlog_rel!("An NFT marker without .fset3 cannot be used for initialization/detection.");
150152
eprint!("Continue anyway? [y/N] ");
151153
let _ = std::io::stdout().flush();
152154
let mut answer = String::new();
153155
std::io::stdin()
154156
.read_line(&mut answer)
155157
.expect("failed to read input");
156158
if !answer.trim().eq_ignore_ascii_case("y") {
157-
eprintln!("Aborted.");
159+
arlog_rel!("Aborted.");
158160
std::process::exit(1);
159161
}
160-
eprintln!();
162+
arlog_rel!("");
161163
}
162164
}
163165

0 commit comments

Comments
 (0)