© Shing Lyu 2020
S. LyuPractical Rust Projectshttps://doi.org/10.1007/978-1-4842-5599-5_2

2. Building a Command-Line Program

Shing Lyu1 
Amsterdam, The Netherlands


Command-line programs, also known as CLIs (command-line interfaces), are one of the most natural applications of Rust. When you compile your first Hello World program, you are building a command-line program. A typical command-line program takes arguments, flags, and sometimes standard input and then executes its main algorithm and output to the standard output or file. All these operations are well supported by the Rust standard library and the third-party crates on crates.io.

There are a few advantages to building a CLI in Rust. First, the rich collection of libraries on ...

Get Practical Rust Projects: Building Game, Physical Computing, and Machine Learning Applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.