Creating a Select Menu in bash using JSON input -


I am trying to create a menu using the selection function. I'm reaching an API that will return its output to json format. I will then process the API that returns to a lower statement where a user can then interact with them.

Here's the API call and how do I parse the output:

  curl -h "authorization: beerer $ ACCESS_TOKEN" https://api.runscope.com/buckets \ | Python-mjson.tool> Output.json  

This will send the output from the kernel through the Jason Parsing tool and finally send the output to the Jason file.

Then I created an array using it: I had to set IFS to properly parse the Jason Blob file:

  IFS = $ "\ n" Nonsense = ("$ (jq. '.data |. [] .name' output.jason)")  

I then add an exception option to the array so that the user can not go out of the selection menu Finally, I will create a menu:

   Select dollar in nonsense; " Bucket $ in "Exit"), "Exit ..." Brake echo;; Esac echo "You selected: $ bucket"  

Unfortunately, this does not make the exit option I can leave the option option to see another menu in which I want to have all the alternatives in the menu and the array are their approximate quote. How do I show the exit option?

< P>

$ nonsense before R is fuck element Arem.

Again, the word is being split and your selection is used as entries.

Since you are blocking word splitting in double quote marks in the jak subshell (and this means that IFS changes do nothing Which I believe to be).

Iff may contain and spaces in your entries, you want the way to properly arrange an array is that Jq with a while IFS = reading-r entry; Loop.

  nonsense = () while IFS = read -r entry; Bucket + = ("$ Entry") done & lt;  

Then add your exhaust item to the array. "$ {Nonsense [@]

} "Choose nonsense; << Code>

( Choose either one; or select there is no requirement; and \ n there.)

Unless you need output.json Can escape.

  nonsense = () while IFS = read -r entry; Bucket + = ("$ Entry") done & lt; & Lt; (Curl-H "Authority: Bearer $ ACCESS_TOKEN" https://api.runscope.com/buckets | python -mjson.tool | jq '.data |. [] .name')  
< / Div>

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -