ZupIT / ritchie-cli

Ritchie CLI is an open-source tool that allows to create, store and share any kind of automation, executing them through command lines, to run operations or start workflows ⚙️ 🖥 💡
https://docs.ritchiecli.io
Apache License 2.0
559 stars 102 forks source link

Reduce qnt of parameters in Run method in node #432

Closed danieldrewszup closed 4 years ago

danieldrewszup commented 4 years ago

After creating a new formula in node you can see in index.js a bunch of const definitions for each input parameter defined at config.json being passed as arguments to the Run method. So when is too many? We can use destructing in ES6 a small example would be that:

index.js run(process.env) formula.js function Run({FOO, BAR}) {}

Improving, whould be nice to have a object and forms to retrieve it (for any type of project). One object called Settings and inside of it we have all possible default configurations for int, string, bool values... And 'forms' of retrieving it already typed. Below you can see a small example in C#:

using(Settings setting = new Settings()) {
    int x = setting['PROPX'].GetInt();
    string y = settin['PROPY'].GetString();
    ...
    setting['PROPZ'].SetInt(230);
    ...
}
kaduartur commented 4 years ago

Hello @danieldrewszup, can you open an issue in the formula project to edit the formulas templates?

Because the ritchie-cli only sends the environment variables to the formulas.

Thanks for your collaboration!