Department Manager
Department Manager
A Command Line Interface program to manage the employees of different departments in a company. Simple project for understanding and practicing writing Command Line Interface Programs with intuitive commands.
Introduction
This is an simple personal project that I tackled because I was feeling like writing a somewhat simple CLI program. The idea was to write a program to manage employees of a company, organized by departments. At first, the idea was to write something similar to a Terminal User Interface, in which the user enters something reminiscent of an interactive menu. In which the user would read the available options, alas, “1. List Employees. 2. Add New Employee” and so on; then the user would input the desired option and so on… After a while I realized this approach, although doable and viable, was somewhat clunky and reminded me too much of school projects. So I decided to take it up a notch, at least slightly.
Implementing a simple CLI program implies understanding about Command Line Arguments and using a method to store data. For the sake of convenience and brevity, I decided to use simple CSV files. The result is a simple interface controlled entirely by command line arguments. This however ends up being very similar to a functional API in esscence. Of course, a production API would take many approaches to improve performance, reliability and accessibility, as well as maybe using other methods for storing data, most likely some kind of database, but in the end, the experience is similar and the learning bridge has been greatly reduced.
Installation
|
|
Then you can run the executable via:
|
|
Or you can install globally so you can run it from anywhere:
|
|
Usage
This is a command line interface program, you do everything giving arguments to the program. Display the help dialog by doing:
|
|
The available options are:
|
|
Listing employees
You can list employees like so:
|
|
Or you can search employees by department name by doing:
|
|
This will list all employees who are in the specified department.
Finding an employee
You can search for a specific employee like so:
|
|
This will list all employees with the specified name. This function can be improved by modifying the CSV structure and allowing full names in different fields, so that we could search for names or last names. But for now I think the example is sufficient.
Adding a new employee
You can add a new employee like so:
|
|
Final thoughts
This project can be further worked upon. As mentioned above, I can improve the employee finding functions in order to be able to make more specialized searches. I also thought about turning this into a full TUI (Terminal User Interface). A remove employee function could also be useful, and so on and so forth, but I think this project is sufficient as a good starting example.