rackspace/rack

Need to return more than one --fields for block-storage

Closed this issue · 1 comments

As an example, when looking for a bootable volume, I tried to use more than one --fields flag.
None of these combinations gave me what I wanted:

$ rack block-storage volume list --fields bootable id
error   Expected 0 args but got 1
    Usage: rack block-storage volume list  [flags]
$ rack block-storage volume list --fields bootable --fields id
ID
18d361d1-2875-458b-9917-65010e37982a
88f2a1b0-b5f7-4634-ac4c-5e7ef0d9b2ac
6efa7008-ada7-4438-9033-efba4aa5cb06

A single field does list one field, of course.

$ rack block-storage volume list --fields bootable 
Bootable
true
true
false

Can I get the tool to return Bootable and ID in one command?

When you get an error like that, it means the command you're trying to run has a word that is being interpreted as an argument instead of the value of a flag. In these cases, it helps to read the help text for the command. Here is an excerpt from the output of rack block-storage volume list --h:

--fields    [optional] Only return these comma-separated case-insensitive fields.
        Choices: id, name, bootable, size, status, volumetype, snapshotid

Now we know that the argument to the fields flag is a comma-separated list of fields. That takes care of one of the problems, but a second problem still exists. Namely, rack block-storage volume list --fields bootable, id will not work either. This is because of how the text gets parsed, and it's done by tokens. White-space indicates the start of a new token when words are not enclosed in quotation marks and so in this example id will be treated as an argument instead of a value. We at last arrive at the correct syntax:rack block-storage volume list --fields bootable,id