clack icon indicating copy to clipboard operation
clack copied to clipboard

Using clack with bash to run command for each object in array

Open PlumpMath opened this issue 2 years ago • 2 comments
trafficstars

Hi @clumsyjedi how to Using clack with bash to run command for each object in array?

example: $ cat x.json | clack -i js :str-lists [ "a" "b" "c" ]

This works fine.

$ cat x.json | clack -i js :str-lists | CMD item

I want the last command to be run with iterate . Is there any possible way?

In addition, it would be nice if there was a way to create multiple lines of text.

Thanks.

PlumpMath avatar Feb 01 '23 07:02 PlumpMath

Assuming I understand your questions you can try:

echo '[1,2,3]' | clack -u -i js 

which would give you :
1
2
3

For raw strings try:

echo '["foo", "bar", "baz"]' | clack -u -i js -o s

The -u flag means "unwrap" arrays
The -o s flag outputs raw strings, so on a string this removes the '"' chars

clumsyjedi avatar Feb 01 '23 07:02 clumsyjedi

I did as you told me, When bb was mixed, pipe args and bb args could be input separately. it's awesome Nice! Thanks~

PlumpMath avatar Feb 01 '23 11:02 PlumpMath