Skip to content

Replace structopts with pico_args

Matti Viljanen requested to merge use-pico_args into master

I stumbled upon this comment:

// sailjail only accepts -prestart on the command line as optional argument, structopt however only supports --prestart.
// XXX: Get rid of this when the situation changes

So I thought I'd look for alternatives, especially when I noticed that structopts uses clap which is considered quite dependency-heavy. I ended up with pico_args which is good enough for our simple use cases, I belive.

How much lighter, you may ask?

Before:

  • 446 crates
  • 26_093_784 bytes (unstripped)
  • 16_603_256 bytes (stripped)
  • clean build 1334 seconds

After:

  • 438 crates
  • 25330976 bytes (unstripped)
  • 16169080 bytes (stripped)
  • clean build 1307 seconds

Change:

  • 8 crates less
  • 762_808 bytes or 2.92% saved (unstripped)
  • 434_176 bytes or 2.62% saved (stripped)
  • clean build 27 seconds faster

The build was run on an AMD Ryzen 9 5950X single-threaded, for aarch64 4.5.0.18 target. The binary was stripped manually using aarch64-linux-gnu-strip on the build system.

The --verbose and --version flags were tested and were effective as expected, and --captcha was able to receive a full-length token obtained from signalcaptchas web site.

Merge request reports