CLI To-Do App “Finished”

Hey Everyone!! I just wanted to put out this last update on the program called ‘Jeeves’ – a CLI To-Do App that I’ve been building with Nodejs. This is as far as I’d like to bring this little butler-app / personal project. At this point almost everything works; the libraries/imports, ASCII graphics, conditional options block, as well as the login(), addToDo(), and removeToDo() functions all work. Now for the bad part; the conditional options block kind of sucks as I will explain later…

I’ve added some ASCII graphics that greet the user when validly logged in, shoved it all into one file, and pushed it to gitHub. Check it out here:

Terminal screenshot shows time/ login info, graphic, options.

I’ve imported ‘prompt-sync’, and ‘moment’ to allow Node to have a prompt function as well as get the current date/time and print it to the screen. I’ve created the function passUser(), which when called, ask for a username and password and if both are correct passes user to next step, if not uses process.exit to exit and get out.

The next part displays the ‘Jeeves’ ASCII graphics. I’ve found a developer that built a sweet app that converts your typing into different styled ASCII art. Pretty fricken cool I’d say! Here’s his site: All I had to do is copy/paste then add extra escape characters since / is itself is an escape character in JS. I tried to add a little butler face drinking a coffee but it looked more like “Texas Chainsaw Massacre” than the polished, sophisticated feel I was going for.

I had started the project with objects as the primary architecture but changed it over to arrays with functions manipulating them as that was easier to understand frankly. I like working with objects but I felt arrays containing strings were a more manageable way to go. (I think this is where I went wrong…Should have done an array of objects…)

Starting on line 56 ‘Jeeves’ displays options for you to type; where user input is saved into a variable called input, that is then split into substrings like so:

// use split() method to separate user input string into an array of substrings
let inputArray = input.split(' ');

On line 75 there is an if/else conditional block that basically says: if array[0] == ‘add’ then call addToDo(), else if array[0] == ‘remove’, call removeToDo(), else if array[0] == ‘print‘, then console.log days array, else if array[0] == exit, then exit, else, console.log “Syntax Error, You need to type commands as shown..

if (inputArray[0] == 'add') {
    addToDo(inputArray[1], sun);
} else if (inputArray[0] == 'remove') {
    removeToDo(inputArray[1], tues);
} else if (inputArray[0] == 'print') {
} else if (inputArray[0] == 'exit') {
    return process.exit();
} else {
    console.log('Syntax Error. You need to type commands as shown.');

This whole conditional block of code only seems to work with the first item in the days array. It seems to recognize inputArray[0,1], but not inputArray[2]. The addToDo() and removeToDo() functions work well, but adding dayFinder() as an attempt to hack this crazy code block into working, proved totally ineffective.

So let’s go over the addToDo() function instead. addToDo() takes 2 arguments; todo, and day. We loop over the days array with a for-loop, the conditional part of which compares the variable i to the length of the days array. If the current day is equal to the day in the days array, it simply appends the new item into the days array with the .push array method.

// AddToDo function that takes 2 args (todo, day)
function addToDo(todo, day) {
    // loop over days
    for (let i = 0; i < days.length; i++) {
        // if input day is equal to day in days array 
        if (days[i] == day) {
            // update day array with .push with the todo string

The removeToDo() function does practically the same thing with the exception of using .pop method instead of .push.

// RemoveToDo function, takes 2 args (todo, day), .pop removes
function removeToDo(todo, day) {   
    // loop over days
    for (let i = 0; i < days.length; i++) {
        // if input day is equal to days array
        if (days[i] == day) {
            // remove todo from day array

Ignore the dayFinder() function on line 115, it’s total garbage. It was just an experiment to try to iron out some of the problems but didn’t work. lol. Line 128 onward are just some calls for testing the functions. I’ll leave the code gist here too just incase someone wants to check it out / use it / finish it!

Check out the code here:

Author: John McKirdy

Husband, Father, Computer nerd, Fat fitness junkie, MMA fan, Wildebeest

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s