Contributing to More Open-Source Repos
Tags: opensource, csharp, programming, beginners
Published: 2023-10-06 17:14:41

As I started working on a new open-source project to add new features, the existing command line argument parser in [Learn2Blog](https://github.com/Yousef-Majidi/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](https://github.com/Yousef-Majidi/Learn2Blog/issues/16) 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](https://github.com/Yousef-Majidi/Learn2Blog/pull/17) which got merged in commits [#a13484b](https://github.com/Yousef-Majidi/Learn2Blog/pull/17/commits/a13484b80b98d3a0f32d20c364e7c8e55d7cb5d0), [#90ea247](https://github.com/Yousef-Majidi/Learn2Blog/pull/17/commits/90ea2470f46649c9c338bb9592b59f563559d454), and [#40e1300](https://github.com/Yousef-Majidi/Learn2Blog/pull/17/commits/40e1300db0f4f789b2e44ddf4b4c1de568e7aada).

## 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!