BuildOn First Project - TextFinder

BuildOn Project - TextFinder

Figure 1. TextFinder Packages
The first BuildOn project, TextFinder, is described here. After that we will layout the first step for this BuildOn. Figure 1. shows a package diagram for our first project with five packages. If you look through the repositories in this site you will find a RustTextFinder repository that is similar, but not identical, to this first project. The idea is that you can use as much of that project as you like, but will write additional code to meet our specifications. This project has slightly different structure and different specification for each part. TextFinder is a program that accepts from its command line a path, a set of file patterns, a text specifier, and zero or more options. It returns the path and name of each file that contains text matching the specifier. The TextFinder program is small enough to be relatively easy to understand, but rich enough to use a lot of the most important features of Rust. The first four steps will build: TextSearch, DirNav, CmdlnParser, and Executive and Display packages. That is enough to build a fully function and useful tool. To that, we will add extensions for processing regular expressions for representing text to match and file patterns. Finally we build code that supports parallel execution of text searches.

TextFinder Specification:

  1. Identify all files in a directory subtree that match a pattern and contain a specified text.
  2. Specify root path, one or more file patterns (.h, .cpp, .cs, .rs, ...), and search text on command line.
  3. Specify options /s [true|false], /v [true|false], /H [true|false] /h [true|false] for recursive directory walk, verbose output header, Hidden dirs with no match, and help message, respectively.
  4. Display file name and path, without duplication of path name, e.g., organized by directory, for files containing the search text.
  5. Interesting extensions:
    • Replace text by regular expressions for both search text and file patterns.
    • Replace sequential file searches with parallel searches to improve performance and useability.
TextFinder structure is shown in the package diagram, Fig. 1. The Executive uses CmdlnParser to extract parameters and options from the commandline. Executive then creates instances of DirNav and TextSearch, passing a reference to TextSearch to DirNav, allowing DirNav to call TextSearch each time it finds a file of the specified patterns. TextSearch seeks specified text and if found sends the path and file name to Display. The Display package turns the sequence of successful search completion events into useful user information. Table 1., below, provides a few references suitable for Rust beginners. They all assume competence in some modern programming language, but not with Rust. You will find references specific to the first BuildOn step #1 in its References Table 1.
 

Exercises:

  1. Look at RustBites Functions and do the exercises at the end.
  2. Look at RustBites Structs and do the exercises at the end.
  3. Look at RustBites Tooling and read part 3., Development Process. Now build a library with a simple demo type (struct). Provide an application in /examples that links to, and demonstrates the library. Something very simple is all you need here.
 

Table 1. - Starting Rust References

Topic Description Link
Look here first Starts with quick to intermediate tutorials on the Rust language. Getting Started
Hello World A quick taste of how C++, Rust, and C# are similar and different - the infamous HelloWorld program. Hello Worlds
Hello Objects A quick taste of how C++, Rust, and C# create and use objects. Hello Objects
Start with first three refs, above. Rest will be useful later.
easy-rust This is an extensive github Readme.md file with table of contents and most of the ideas expressed in simple language with lots of details. easy-rust
Safety Rust definitions, invariants, syntax checking rules, and types that make Rust code safe by construction. Rust Bites Safety
Ownership Discussion of the ownership rules with several small code examples. Rust Bites Ownership
Rust Story A narrative walk through of the Rust Language, provided by this site. Rust Story
Rust Bite by Byte A sequence of small bites from the Rust language with examples. Rust Bites
 
 toggle menu