Writing CLIs in Rust is awesome

…and it’s getting even better

Pascal Hertleif

2018-03-28

Hi, I’m Pascal

{twitter,github}.com/killercup

What we want to do

  • famous crates: work with their authors to improve and stabilize
  • write guide-level documentation
    • pitching Rust as a great lang for CLIs on the new website
    • for specific crates and use cases

Survey

  • 1,045 replies
  • we’ll post pretty pictures soon

Areas we are focussing on

Handling CLI input should be concise

  • clap 3.0 with custom derive
  • config files, env vars, CLI flags build a configuration
    • best-practice-as-a-crate

Outputting stuff in CLI should be frictionless

  • streaming and pipe handling
  • logging
    • for humans and machines
    • best-practice-as-a-crate

Testing

  • assert_cli refactoring & 1.0
  • guide on testing cli apps

Distributing

  • Coordinate and consolidate already existing efforts
  • we can’t do everything, but we can provide guidelines and scaffolding!

This is happening fast

Quicli

  • re-exports commonly used items from other crates, e.g. structopt’s derive
  • provides helpers like read_file (-> String)
  • gives you a main! so you can do ? “in main” (and get logging set up)
  • since quicli 0.1 in january:
    • rayon 1.0 shipped
    • failure 1.0 announced
    • CLI WG started
  • quicli might become obsolete soon!
    • clap 3 with include a custom derive (ETA: Before Rust 2018)
    • std::fs::read_string (bikeshed half painted)
    • ? in main will be stable very soon

…please keep doing this, folks

Thanks!

Come to the CLI WG meeting at 10pm in the “Snow” room

Slides available at git.io/rust-all-hands-cli-wg