What Are the Precautions for Using cli-output-rows, cli-output-cols, and cli-output-num?
If --cli-output-rows, --cli-output-cols, and --cli-output-num are used in a command, the command output is in table format. Table output helps you extract key information from return values. The parameters are described as follows:
- --cli-output-cols: the fields to print during table output.
- --cli-output-rows: the levels to print during table output. For example, if you want to convert a JSON structure to a table, set this parameter to the name of the structure.
- --cli-output-num: whether to print the row numbers during table output. The value can be true (default) or false.
For details, see How Do I Use cli-output-rows, cli-output-cols, and cli-output-num?
Note the following when using the preceding parameters for table output:
- --cli-output-cols and --cli-output-rows can be used separately or together.
- Use only --cli-output-rows.
The --cli-output-rows option is separately used in a command to pass the name of a JSON structure in the calling result. The levels must be separated by periods (.). The content of the target JSON structure must be an array. KooCLI will display the structure content in a table. For example, if you run the hcloud configure list --cli-output-rows=profiles command, all profile information will be displayed in a table. If the JSON structure specified in --cli-output-rows is not an array, the following error message is displayed:
[CLI_ERROR] Table output error. The cli-output-cols parameter is required.
- Use only --cli-output-cols.
The --cli-output-cols option is used to pass the root element fields of the JSON structure of the calling result. The fields must be separated by commas (,). For example, if you run the hcloud configure show --cli-profile=${profileName} --cli-output-cols=accessKeyId command, the access key ID in the specified profile will be displayed in a table. When --cli-output-cols is used separately, only the root element fields of the JSON structure can be specified. Otherwise, the following error message is displayed:
[USE_ERROR] In parameter cli-output-cols, * is null.
- Use both --cli-output-cols and --cli-output-rows.
The --cli-output-rows option is used to specify the levels to print, and the --cli-output-cols option is used to specify the fields to print at the levels. For example, if you run the hcloud configure list --cli-output-rows=profiles --cli-output-cols=accessKeyId command, the access key IDs of all profiles will be displayed in a table.
You can set --cli-output-rows to [n] or [m:n] to specify the index of the array element to be printed. Specify [n] to print the value of index n, and specify [m:n] to print the values of indexes m to (n – 1). For example, if you run the hcloud configure list --cli-output-rows=profiles[0:2] --cli-output-cols=accessKeyId command, the access key IDs of the profiles whose indexes are 0 and 1 in the profile array are displayed in a table. Pay attention to the following:
- If the index value of the array in --cli-output-rows is [m:n] and the value of n exceeds the array length limit, data within the maximum index will be printed.
- If the index value of the array in --cli-output-rows is [n] and the value of n exceeds the array length limit, an error message is displayed indicating that the array index is out of range:
[USE_ERROR] The cli-output-rows parameter contains an incorrect field (*). The array index is out of range and the array length is *. Current index: *.
- When both --cli-output-cols and --cli-output-rows are used, the parameters in --cli-output-rows do not need to be of the array type. You only need to specify the level.
- Use only --cli-output-rows.
- When --cli-output-num is used separately, the output will not be displayed in a table.
- In the same command, --cli-output-rows, --cli-output-cols, and --cli-output-num cannot be used together with --cli-json-filter. Otherwise, an error occurs because the output format cannot be determined.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.