niieani / bash-oo-framework

Bash Infinity is a modern standard library / framework / boilerplate for Bash
https://github.com/niieani/bash-oo-framework/discussions
MIT License
5.57k stars 247 forks source link

New named parameters implementation #86

Closed nkakouros closed 5 years ago

nkakouros commented 5 years ago

As already mentioned in #45, I have taken inspiration from a nice trick I found online. I expanded upon it to create the same aliases as in v2.

This is a proposal and if you find it appropriate we could work on it to expand it to fully cover v2 aliases or introduce new ones as well. For the time being I have created the [string] and [integer] aliases.

In the code, I think it would be nice to add comments to guide future contributors. I have added some minimal ones so far. Also, contrary to the previous implementation, I named internal variables that are not leaked to the calling code with friendly names to make it easier to follow the flow. Functions, aliases, etc that will be available in the scope of the caller have been namespaced with bash_oo_<library-name>. I have also set -eu (probably should have added -o pipefail). I think it would be a good idea to enable strict mode and take care of initializing our variables and handling any error. Moreover, I have used shfmt to format the source code.

I have tried to follow a TDD approach. As we have already discussed, I have used bats and a couple 3rd party libraries instead of rolling our own custom test suite. To run the tests, there is script that can be called with bin/run_tests.

nkakouros commented 5 years ago

I also added a travis.yml. I think I should have better reused the travis.yml from v2.

nkakouros commented 5 years ago

OK, I replaced my travis.yml with the one from v2.