© 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 
(1)
Amsterdam, The Netherlands
 

Introduction

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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.