DEV Community

Cover image for Contributing to More Open-Source Repos
Omar Hussein
Omar Hussein

Posted on • Updated on

Contributing to More Open-Source Repos

As I started working on a new open-source project to add new features, the existing command line argument parser in Learn2Blog had a peculiar issue.

First Glance

It was reading arguments in a way that didn't align with the standard conventions. The parser interpreted arguments as "flag command_arg flag_arg," which was confusing and non-intuitive. To address this, my first task was to restructure the argument parsing logic to follow a more logical sequence: "flag flag_arg command_arg." This change made the application's interface much more user-friendly and intuitive.

Also, the initial implementation of the argument parser was static and didn't account for dynamic inputs. It simply used array indexing to get arguments. I refactored this logic by implementing a loop that iterated through the arguments, parsing them in a standard manner. This dynamic approach ensured that the parser could handle varying numbers of arguments without breaking, making the application more robust and adaptable.

Introducing TOML Config Support

While fixing the command line argument parser was essential, my main reason for contributing to Learn2Blog was to introduce a new feature: support for TOML configuration files. TOML (Tom's Obvious, Minimal Language) is a human-readable configuration file format that's easy to write and understand. By allowing Learn2Blog to read from a TOML config file, users now have a powerful tool at their disposal for configuring the application with precision and ease.

I simply started by submitting an issue and awaiting the owner of the repository to approve my enhancement.

The implementation was straightforward: the app reads the TOML config file and utilizes the same flags as the command line arguments. This means users can specify their preferred options in the config file, providing a more organized and maintainable way to manage the application's settings. The options specified in the config file always take precedence over command line arguments. I ended my contribution by submitting a pull request which got merged in commits #a13484b, #90ea247, and #40e1300.

My Experience

Working on Learn2Blog has been a interesting experience. Refining the command line argument parser and introducing support for TOML configuration files helped me learn a lot about C# through such a small contribution. It was refreshing to use C# after such a long time on Linux and have it work so flawlessly but I still have a slight resentment for C#'s syntax and how verbose it can be. Overall I enjoyed working on a language I haven't used in a while and would definitely consider working on it again!

Top comments (0)