DEV Community

Devansh Shah
Devansh Shah

Posted on

Working with Branches adding Features

The start

This week, I set out to add 2 feature to my FireLinker release 0.1. The feature I choose to add was json output and proper exit codes. I also wanted to gain a greater understanding of working with branches previously in my data structures class I had used them for my labs while I was working on them. This was however my first time using it on an active project so at the start of last week I started trying to implement 2 feature using branches.

Feature 1 - JSON output

To implement JSON output at first at I though it was going to be easy. Where all I need to do was just use JSON.stringfy(links). That is what I did but the trouble I encountered was with yargs my command line interpreter. This was going to be the first option flag that did not come with yargs. So, after reading the documentation for a long time I finally figured out. How I would implement the option flag for the tool. This was to check both the j flag argument and the first argument. Yargs is smart enough to not add them in the same structure. With, this I implemented the feature. I added the source file to staging area but I forgot to commit and quit for the day.

Feature 2 - exit codes

This feature was simple I just have to exit with non-zero code if not all links are successful. I implemented this with a global variable called exitCode with the initial value of 0 and then I incremented it for every un-successful link. The source file was then added to the staging area and I committed the feature to branch 2 and then I merged to the master branch.

The End

After, I merged branch 2 I checked my source file and had a mini heart-attack. I did not see the changes I made but the I membered I had not committed and merged the changes in branch 1 and I final saw the fruits of my effort both features on the master branch. It was then committed to GitHub.

Discussion (0)