DEV Community

Cynthia Fotso
Cynthia Fotso

Posted on

Adding a New TOML Feature, using Git Remotes and Merges on a repository.

I worked on adding a new feature to my classmate's repository, repo2context, a Go-based project that generates structured markdown from a repository. My task was to implement TOML configuration file support so that users could control options such as no-gitignore, display_line_num, and verbose through a config file instead of always passing CLI flags.

How did the code itself go?

This was very challenging programming-wise since the project was written in Go, a language I had no prior experience with. It took me a lot of time to review and understand the code, and then figure out how to implement the new feature.

I filed issue#26 in my classmate’s repo. While going through the code, I noticed it used Viper (a Go config library) to load options. I modified the project's CLI initialization to detect .r2c-config.toml in the current directory and merge values so that CLI flags override config file values.

Did you run into any problems?

Yes. One challenge I ran into was that the program kept printing the default scan options (NoGitignore: false, DisplayLineNum: false) even though I had set them to true in the .r2c-config.toml file.

How did you tackle the work?

To solve the problem, i added a merge step in initConfig() so that only options not explicitly set through flags would be replaced by config file values. This ensured the TOML file was respected.

How did it go using git?

It was pretty smooth at the beginning, but I got a little confused since I usually open a pull request directly instead of starting with a Draft Pull Request. I read the documentation on GitHub and figured it out. I opened this Pull Request.

Did you find any of it difficult?

Apart from the small Git confusion, not really. I actually enjoyed working on my classmate’s repo. We were both engaged and responsive, which made the process move faster.

What would you do differently next time?

I’ll practice more Git commands next time so I don’t have to constantly look them up. Tasks become easier when you know the commands by heart.

What did you learn from the experience?

I learned that even if a project looks intimidating especially in a language you’ve never used before, if you’re willing to put in the time and effort, you can still achieve your goal and gain new skills.

I learned how to implement configuration file support, and I also gained valuable experience collaborating on a real project using forks, branches, and pull requests.

Top comments (0)