Open nkakouros opened 6 years ago
Fix is here, in the rewrite of the named parameters functionality: https://github.com/niieani/bash-oo-framework/issues/41#issuecomment-362107200. To get it merged I'd need to provide a backwards-compatible layer for the older syntax, I didn't have time to do it yet. Unless we do it as a breaking change and release 3.0. What do you think?
But it works with the new version:
function q {
args : @required string command
echo "${command-UNDEFINED}"
}
q 'some value'
Prints: some value
I was thinking about this for quite some time. Here is my suggestion.
Version 2.0 receives no further features, fixes, etc except those that are critical and no easy workaround can be found. For instance, for the issue here you can easily rename 'command' to 'command_name' or sth else. Or for #41 you can end all named parameters sections in functions with a :
and you are good to go.
For version 3.0 onwards, I suggest a slight change in the development approach. I think that we should aim for the framework to be written from scratch. Just to not create unwanted impressions, what you have already achieved is one hell of a clever project and I still stand in awe of your achievement. By rewriting, I simply mean to start from an empty state, not try to just patch the previous version. We can start from the entry point of the project (oo-bootstrap) and move to each module one by one. Code reuse could, will and should happen, but at every step there should be 3 criteria on whether to commit (old or new) code:
While developing, tools like shellcheck, shfmt, etc could be used to help produce as quality code as possible. Also, a git workflow (eg gitflow) could be adopted.
Moreover, it seems important to me to place Bash Infinity into a broader ecosystem of bash projects and cooperate with some significant ones (like BATS or go-script-bash). Technically, this translates into two things:
Another issue to consider is platform and bash version support. From my point of view, someone that wants to use Bash Infinity to develop a bash project will have no problem updating their bash version to the latest available. It would be surprising to see someone choose to develop a whole project/application in Bash plus try to reduce development pain with the use of a framework and yet have issues updating their bash version. Thus, I think that development should be more or less done against the latest Bash version.
Finally, sth that is more like a wish of mine is to make it easier to use the project by providing stuff like syntax highlighting and auto-completion files for eg vim or atom.
The above are some thoughts I have been having and if you agree on some we could further discuss them and act upon them. Time is a scarce resource but there is no hurry here. I am interested and willing to help build little by little the new version.
Great points @tterranigma!
I wholeheartedly agree about the clean-slate and all of your criteria for it.
Just as I've started with the re-write of named parameters -- a clean slate here really helped to create a much shorter and easier to understand code.
Similarly, I've been experimenting with a better importing system, which does not pollute the global scope. See the example here.
Regarding your last point, I've also been exploring the "better tooling" avenue -- the experiment was to try and re-use tooling from a different language. My first try is to adapt TypeScript, i.e. use a limited set of expressions and emit clean bash
.
It's a wild project, but I've already got something running locally -- it's a different take on the issue, and possibly a separate project to Bash Infinity.
But going back to the idea of 3.0 -- let's do it! 🔥
Here is an example script:
Running this prints 'UNDEFINED'.