October 2019
Intermediate to advanced
444 pages
10h 37m
English
clap (https://clap.rs/) prides itself on being a simple-to-use crate for working with command-line arguments in Rust—and they are right. In the initial two steps, we set up the application config and dependencies. We also renamed the binary since list is a more to-the-point name than command-line-args.
In step 3, we start by importing the necessary structs (https://docs.rs/clap/2.33.0/clap/struct.App.html)—App, Arg, SubCommand for clap, and, in step 4, we are creating the function that we are going to parameterize using command line arguments. The function itself is a simple directory tree walk with the ability to execute a callback on each entry and a way to exclude certain paths as an exclusion.
Read now
Unlock full access