DEV Community

Kien Nguyen Chi
Kien Nguyen Chi

Posted on

OSD600 - Week 5 - Lab 4

Introduction

==============
This week, I work with Gus to implement the --config feature to add .json file on our SSG. We work on the same language C++, which makes us easier to talk about the project.

The structure of my ssg and his ssg is quite different. I implement several classes for each specific task. Otherwise, he has only one main file and a header file. It is quite long to read.

Adding Features

=================

gasHeader.h

1/ Adding prototypes for 2 new functions getJsonValue() and processJsonFormat().
2/ Changing prototypes for processText() and newFolder() to receive default arguments. If no arguments provided, the default values for stylesheet, lang would be empty string and default values for outputFolder would be "./dist". This changes would not affect the current structure of current program.

gasMain.cpp

1/ main function: slightly change the structure. If the command argument is either "-c" or "--config". It will go to an if statement and go to process processJsonFormat(). Otherwise, it is go to an else statement and process the program as before.

2/ processJsonFormat() function: Retrieve information of input file, output file, stylesheet and lang. If there is no arguments provided in the json file, it is empty string. Then program will process the same way as it performs before except providing arguments for possible output, stylesheet or lang. If there is no arguments provided, it processes the default values as I mentioned above. So there is no conflicts.

3/ getJsonValue() function: Support processJsonFormat() to concatenate values from JSON attributes.

4/ processText() and newFolder() functions: slightly change to make them receive accepted arguments or default arguments.

Other features:

The program would ignore if there are any contents provided in .json file except input, output, stylesheet and lang. Or still process if output/stylesheet/lang is not provided.

If json file is missing or cannot open, appropriate messages are displayed.

Links:

========
Gus's Repo: Github Repo
My Repo: Github Repo
My Issue: Issue #19
My Pull Request: PR #20

Git

=====
The concept of git remote is interesting to use. It is convenient for both the owner and people who folk our repo and review and change the code. I can fetch the code from folked repo to my local machine, so I can review it without affecting to my original code. It is also easy to update new changes from folked repo by git pull. Finally, I can do git merge to merge the successful tasks done by other to my repo.

Overall, Git is a powerful and useful tool to use if you truly understand how it works.

Top comments (0)