A1: Command-Line Interaction

FindFiles Utility

Build a command-line application that finds files. The output prints the absolute path of the located files.

Syntax:
java FindFiles filetofind [-option parameter1 parameter2 ...]

Using this syntax:

Filename

`filetofind` must be supplied. It must be a valid filename for the system, or a pattern that is being matched using the `-reg` flag. It must be enclosed in double-quotes (see examples below).

Options

Options are specific arguments provided to the program on the that determine how it executes. Options always start with a dash ("-"), and may require zero or more additional arguments to function. Options may appear in any order.

`java FindFiles -help` will display all of the supported options.

  Usage: java FindFiles filetofind [-option arg]
  -help                     :: print out a help page and exit the program.
  -r                        :: execute the command recursively in subfiles.
  -reg                      :: treat `filetofind` as a regular expression when searching.
  -dir [directory]          :: find files starting in the specified directory. 
  -ext [ext1,ext2,...]      :: find files matching [filetofind] with extensions [ext1, ext2,...].

Parameters

Most options require one or more additional parameters to operate, which immediately follow the option on the command-line. Parameters cannot start with a dash ("-"), since that symbol is used to designate options. Parameters consist of a string enclosed to double quotes (e.g. "string"). [note: this must be done to ensure that the shell passes the string into your program properly.]

In the case of options that support multiple arguments (described below), they should be separated by a comma. e.g. `java FindFiles img -ext "jpg,png".

Processing Options & Parameters

The following guidelines apply to how you interpret and process command-line arguments.

Valid examples:

Invalid examples, which produce errors:

Technical Requirements

Submission

Your submission should include:

You should submit your project in your GitLab repository for this course (and push to the server) by the deadline.

To grade your assignments, TAs will run commands and check the output. e.g. 
    $ javac FindFiles.java
    $ java FindFiles test1.txt // read output and assign grade

Assessment

Your submission will be assessed roughly as follows:

5%
Complete submission including project file and `readme'. Code compiles and runs.
20%
Correctly parse and identify options and arguments.
25%
Provide feeback on incorrect options and arguments.
20%
Combine multiple options in one command.
30%
Find files correctly using the operations above.

Versions

1.0 Aug 18, 2020. Initial draft.

1.1 Aug 26, 2020. Fixed a couple of typos. Clarified help text.

1.2 Sept 17, 2020. Addressed feedback from Q&A Session. Removed invalid 'makefile' reference. Added section on running/testing.

1.3 Sept 23, 2020. Removed Gradle requirement.