-
Notifications
You must be signed in to change notification settings - Fork 102
List options dynamically #389
Comments
Hi @rasouza! Changes goes on this file: ritchie-cli/pkg/formula/runner/inputs.go Line 99 in c4017a5
|
I'm not sure if I understood correctly, is it implemented already? I can't find the survey package the Thanks! |
@rasouza sorry for the delay, I think I misunderstood on the first moment. The feature is a dynamic list in which command or situation? |
There are cases that I don't know all the options before hand so I can't just type them in In my example, this external service would be GitHub API, and then Another example would be: I want to perform an operation in a pod in my k8s cluster, this operation is so verbose that I decided to keep it in a Solution suggestionI understand that the way you guys designed We could make a new type in This way we can offer the feature without restricting the Formula's language through the shebang interpreter So to illustrate:
#!/usr/local/bin/node
...
const data = await fetch('https://myapi.com/')
return data.map(item => {
{
"name": item.name,
"value": item.value,
}
});
It then unmarshalls this JSON response, renders in terminal and, once an option is selected, pass the |
Hello o/ sorry the late reply They are complementary to each other in a way, yes. Probably the solution you're envisioning solves both issues, so we're good here. However, it's still possible to deliver one value without accomplishing the other: if I create a static step-by-step in
The #390 only suggests that I can hide some options from the formula execution. This #389 serves a bigger purpose indeed and may solve both issues depending on how you implement it. Please let me know if I left anything unclear. I'm looking forward to discuss it through :) |
Hi @rasouza , Thank you again for your suggestion ! I'm currently reviewing all ISSUES and I think we could add the #HacktoberFest tag (https://hacktoberfest.digitalocean.com/) to the ISSUE your created. However, I believe it would be interesting to update the first ISSUE comment with your detailed explanation of how you imagined it (with the Do you want to it or would you prefer if I update it for you ? |
Hello! Sorry late reply again Yeah, it's no problem at all. I think you know it better how this should be done, so do you mind updating it for me? Thanks! |
No problem @rasouza , I updated the ISSUE and associated labels. Thank you again 👍 Note: The documentation (https://github.com/ZupIT/ritchie-gitbook) will need to be updated afterwards. |
Pulling the issue to the cli team, the implementation will be a bit simplified for the sake of delivering value on the short time. Having a per-language request implementation might affect multiple points and become complex to implement, we might be implementing it inside Ritchie |
It makes sense, let me know if I can serve you anyhow |
Implemented by #605 |
What would you like to be added:
Why is this needed:
Explanation
There are cases that I don't know all the options before hand so I can't just type them in
config.json
, so I'd like to render these options in runtime, by calling an external service or something alike.In my example, this external service would be GitHub API, and then
ritchie-cli
would render according to the JSON response.Another example would be: I want to perform an operation in a pod in my k8s cluster, this operation is so verbose that I decided to keep it in a
ritchie
formula. As you know, pods are all ephemeral and have a unique name during their lifetime, so I wouldn't be able create a formula for that since I don't know my pods' names before hand to put inconfig.json
's list. The external service in this case would be the Kubernetes APISolution suggestion
I understand that the way you guys designed
ritchie
, it would require to change a little bit of its architecture in order for dynamic lists to work. So I was thinking about a sort of workaround for that, which could serves well. Feel free to adapt it whenever you believe you shouldWe could make a new type in
config.json
(let's saydynamic
) together with a file path in the current formula's language (e.g.src/inputs/my_dynamic_call.js
). This file, with its proper shebang (this is the workaround), gets executed by Golang'sritchie
and it would be responsible for making the request to the external service and returning a JSON response to Golang in a defined structure (let's say 2 fields:name
andvalue
). Then the CLI would just render allname
fields to the list (by unmarshalling the JSON) and when you select an option, thevalue
field gets passed to the formula ENV variables as it normally would in a static way.This way we can offer the feature without restricting the Formula's language through the shebang interpreter
So to illustrate:
config.json
my_dynamic_call.js
ritchie-cli
: Executesmy_dynamic_call
in SO level and receives a previously-agreed structure:It then unmarshalls this JSON response, renders in terminal and, once an option is selected, pass the
value
field to the environment so I can continue my business rule with the selected option.Comment
It would be complementary to #390
However, it's still possible to deliver one value without accomplishing the other: if I create a static step-by-step in
config.json
, it would be possible to switch between options, without making it dynamic, by creating a new term in yourconfig.json
DSL. E.g.:The #390 only suggests that I can hide some options from the formula execution. This #389 serves a bigger purpose indeed and may solve both issues depending on how you implement it.
The text was updated successfully, but these errors were encountered: