DEV Community

Cover image for 30 Days of Rust - Starting the CLI tool
johnnylarner
johnnylarner

Posted on

30 Days of Rust - Starting the CLI tool

For those of you paying attention, you may have realised that I didn't post a blog yesterday - sorry for that 🙈 Now I'm back to start my first project written in Rust. The plan is to create a simple CLI tool that measures the time elapsed running a command in your terminal. In this blog post, I'm going to sum up my learning objectives as well as some feature requirements for the first iteration of the project.

Objectives and key results

Lets start by naming some learning objectives for the project:

  1. Packaging and exporting a Rust executable
  2. Building a robust and maintainable tool by applying TDD principles
  3. Familiarising myself with the Rust standard library

Cool, now we know at a higher level what we're trying to achieve, it's important to outline some kind of rudimentary product vision. This will be expressed in problem terms and feature ideations:

  1. I want to easily and reliably test how fast my programs or library components run;
  2. We have good unit and integration test suites, but don't have resources to commit to non-functional testing;
  3. I develop locally with large amounts of data and want to check memory or CPU bottlenecks.

I can see a CLI solution to these problems. But problems 2 and 3 would require advanced capabilities. Focussing in the first iteration on solving problem 1 seems reasonable. There are suitable features that should get some of the problem's requirements solved:

  1. "Test easily" -> One line installation, simple inward and outward APIs, language agnostic
  2. "Test reliably" -> Robust error handling, taking averages over results.

Before breaking these down further to actionable steps, let's look at some prerequisites that need to be sorted first.

Project setup

Including the right linting and testing tools as well as commit hooks can reduce the burden of project management overhead. The company I work for has an open-source project template for Python. I'll first look to find a similar template to that. From there we'll then initialise a public git repo and work on the very first feature areas.

Starting features

There are two major starting points for this project:

  1. CLI installation and arg parsing;
  2. Process management and meta data collection.

At this stage I'd feel more comfortable starting with objective two. I'll start with TDD and see how that goes. Once I've got the ability to start and await the completion of a subprocess, I'll pause and go to objective one. My aim is to create an automatic test suite for the CLI aspect.

What to expect from the blog?

Each day I'll run through the questions and answers from the previous day and then move on to describe some of the challenges I encountered. Apologies in advance for terrible GIF or pun action 😄

Top comments (0)