yvt/Stella2

Command-line argument processing

Closed this issue · 3 comments

yvt commented
  • Full parsing — Find a lightweight alternative of clap or write one. Maybe clap is small enough if all features are turned off?
  • Minimal CLI for macOS and Windows which are more GUI-centric. Only accept -h/--help or accept nothing at all
yvt commented

Base version: 3aebf68

#[derive(argh::FromArgs)]
/// A lightweight instant messaging client.
struct Args {
    /// the path to a custom profile directory
    #[argh(option)]
    profile: Option<String>,
}

let measure_start = unsafe { std::arch::x86_64::_rdtsc() };
let _: Args = argh::from_env();
let measure_end = unsafe { std::arch::x86_64::_rdtsc() };
dbg!(measure_end - measure_start);
Library CPU cycles¹ .text size
None 0 462848
argh 20569 475136 (+12KiB)
gumdrop 23549 475136 (+12KiB)
clap (minimum) 283296 860160 (+388KiB)
pico-args² 26356 475136 (+12KiB)

¹ The minimum value of circa 10 samples. To simulate the common usage, no command-line arguments were provided.

² pico-args does not support help generation. The application handles -h manually and prints a pre-formatted help message.

Screen Shot 2020-02-16 at 23 41 38

yvt commented

Implemented a custom command-line parsing solution in ed5e0d8.

Library CPU cycles¹ .text size
None 0 462848
Custom Solution 20977 471040 (+8KiB)