Skip to content

konstantindt/rust-cmdseq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Specification

The following specification I extracted by playing around with the original project.

This is a command line executable which takes command line arguments in order to function. If the arguments are omitted completely or prove wrong the text message Usage: cmdseq [-d <count dir>] <count1> <cmd1> [... <countn> <cmdn>] should be printed on the console.

[-d <count dir>] optionally allows us to specify the directory where to store program data. The default directory should be set to /tmp.

The important arguments that the user should enter consist of a sequence of pair tuples. The 1st element of each tuple indicates the number of times we should execute the command associated with the tuple. The 2nd element is the command to execute. Running the program executes one command at a time. A note is made of where in the sequence of tuples to select the next command to use next time the program is executed with the same arguments.

The program moves on the next tuple when it executes the command the specified number of times. When the tuple sequence is passed over once the program should being as if when the user ran the program the first time.

Simple error checking consists of making sure that the number of important arguments entered is even so that we can create full tuples from them.

The main functionality is achieved by maintaining a cookie file. The file initially stores 0. Each time the program runs this number is incremented before being written over the original number read from the file except in one special case. When the number becomes equal to the sum of all 1st elements of all tuples we write 0 again in the file to simulate a 'wrap round' of the sequence entered.

In order for multiple command sequences to be safely used, the cookie file name should be generated by appending the string cmdseq. to a unique reference generated by inputting the string of the important arguments to the first hash command we find on the user's system and then selecting the first 16 characters (again using system commands) from the result.

Hash commands that we accept are sha256, sha256sum, md5, md5sum. If those commands are not found prompt No usable hash command found. Install sha256 / md5.

About

Port Laurence Tratt's "cmdseq" to Rust.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages