Mac-Coleman / CSC-311-Scheduling-Algorithms

A process scheduling simulator written in Python for class
0 stars 1 forks source link

Remove Argparse #22

Closed Mac-Coleman closed 1 year ago

Mac-Coleman commented 1 year ago

After our meeting in class, it was decided to remove argparse as it seems like it will not be allowed in this assignment (see #15).

This pull request is to remove the argparse library and replace it with a custom CLI-parsing function. The CLI-parsing function in this PR reads sys.argv and creates a dictionary of program arguments. Every dictionary created by the function will contain a key named "action" whose value will be one of: "help", "version", "use_trace", and "use_config".

For "use_trace" and "use_config", there will also be a "file" key whose value is the path to the file to use as input.

For "use_trace", an additional "algorithm" key is stored, whose value is the algorithm the user specified. All the remaining arguments after the algorithm are packed into a list stored in the "parameters" key. It is assumed that these parameters are positional.

For example, running the command python simulator.py trace.txt rr 4 will yield a dictionary like so:

{
    "action": "use_trace",
    "file": "trace.txt",
    "algorithm": "rr",
    "parameters": ["4"]
}

The implemented scheduling functions should probably be able to raise ArgumentErrors if the parameter list is too long or short for the given command.

Keep in mind that the parameters are not cast, they are left as strings exactly as the user specified them.