How to combine multiple GC commands

I am thinking it would be useful if the output results of a command that outputs a list (e.g. gc routing queues list) could be piped to a command that requires the specification of an id (e.g. gc routing queues wrapupcodes list [queueId]) for batch output.

I tried the following command as a test, but unfortunately, as I assumed, such a command did not work.

gc routing queues list -a --transformstr="{{- range . -}}{{{.id}}{{- end -}}"|gc routing queues wrapupcodes list

Is there a better way to do this?

(I'm updating here because I can't seem to add new comments after the status is closed.)
Thank you Simon and John for your answers.

John
Thanks for the introduction to Archy. That is very cool.
I'm currently working on a project to set up DR in multiple regions with a staging organization, so I'd like to use it to synchronize the flow.

Simon
Regarding the redirection of commands, it seems like it would be difficult to direct each line at the command prompt.
It is very good news that we can execute one line at a time with .net.
I will try it later for a future implementation.

However, this time I would like to complete the process at the command prompt, so I will try to use gotmpl (transformstring) to generate a wrapup list command with queue id and execute it.

Regards,

You are piping a list in one go at a command expecting a single value.
The GC CLI site has links to some examples and also recipes in github CLI

I don't think you can iterate over output in a batch (CMD) window, I would use powershell to give you the flexibility (assuming Windows and not Linux)

In your example you need to pipe into a foreach-object and use $_ to refer to piped value

UNTESTED, just a pointer and not checked your transform, I tend to use go templates in files:

gc routing queues list -a --transformstr="{{- range . -}}{{{.id}}{{- end -}}" | forEach-Object { gc routing queues wrapupcodes list $_ }

Not at PC, so may be bad syntax, but approach is the point.

1 Like

Hi Yusuke,

Simon is exactly right. The CLI does expect a single value. There are a couple of approaches you can take:

  1. Wrapper the CLI with a small powershell or python script. We have several examples you can look at here in our Quickhits repository.

  2. Rather than try to redirect the file to the gc CLI. Use your transformstr flag to write the command you are trying to execute individually into a shell or batch file. I used a similar technique to get a list of the architect flows using the CLI and then generate a shell script of the corresponding Archy export commands. This example can be found here.

Thanks,
John Carnell
Director, Developer Engagement