Reader small image

You're reading from  Practical System Programming for Rust Developers

Product typeBook
Published inDec 2020
PublisherPackt
ISBN-139781800560963
Edition1st Edition
Tools
Right arrow
Author (1)
Prabhu Eshwarla
Prabhu Eshwarla
author image
Prabhu Eshwarla

Prabhu Eshwarla has been shipping high-quality, business-critical software to large enterprises and running IT operations for over 25 years. He is also a passionate teacher of complex technologies. Prabhu has worked with Hewlett Packard and has deep experience in software engineering, engineering management, and IT operations. Prabhu is passionate about Rust and blockchain and specializes in distributed systems. He considers coding to be a creative craft, and an excellent tool to create new digital worlds (and experiences) sustained through rigorous software engineering.
Read more about Prabhu Eshwarla

Right arrow

Writing a shell command in Rust (project)

In this section, we will use our knowledge of the Rust Standard Library on file and directory operations that we learned in previous sections to implement a shell command.

What will the shell command do?

The shell command will be called rstat, short for Rust source statistics. Given a directory as an argument, it will generate a file count of Rust source files, and source code metrics such as the number of blanks, comments, and actual lines of code within the directory structure.

Here is what you will type:

 cargo run --release -- -m src .

Here is an example of the result you will see from this shell command:

Summary stats: SrcStats { number_of_files: 7, loc: 187, comments: 8, blanks: 20 }

This section is structured as four sub-sections. In the first sub-section, we will see an overview of the code structure and a summary of steps to build this shell command. Then, in three different subsections, we will review the code...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Practical System Programming for Rust Developers
Published in: Dec 2020Publisher: PacktISBN-13: 9781800560963

Author (1)

author image
Prabhu Eshwarla

Prabhu Eshwarla has been shipping high-quality, business-critical software to large enterprises and running IT operations for over 25 years. He is also a passionate teacher of complex technologies. Prabhu has worked with Hewlett Packard and has deep experience in software engineering, engineering management, and IT operations. Prabhu is passionate about Rust and blockchain and specializes in distributed systems. He considers coding to be a creative craft, and an excellent tool to create new digital worlds (and experiences) sustained through rigorous software engineering.
Read more about Prabhu Eshwarla