> For the complete documentation index, see [llms.txt](https://docs.console.zenlayer.com/zenlayer-cli/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.console.zenlayer.com/zenlayer-cli/usage/command-structure.md).

# Command Structure

This guide introduces the basic structure and syntax of Zenlayer Cloud CLI commands.

## Command Structure Overview

Zenlayer Cloud CLI uses a multi-level command format with the following basic structure:

```bash
zeno [global-options] <command> [subcommand] [parameters]
```

### Component Description

* **Global Options**: Options that apply to all commands, such as `--profile`, `--output`, etc.
* **Command**: Corresponds to a Zenlayer Cloud service, such as `zec` (Elastic Compute), etc.
* **Subcommand**: Corresponds to a specific operation of the service, such as `describe-instances`, `create-zec-instances`, etc.
* **Parameters**: Specific parameters for the command, such as `--instance-id`, `--instance-type`, etc.

## Command Examples

### Example 1: List All Cloud Server Instances

```bash
zeno zec describe-instances
```

### Example 2: List Cloud Server Instances Using a Specific Profile

```bash
zeno --profile prod zec describe-instances
```

### Example 3: Create a Cloud Server Instance

```bash
zeno zec create-zec-instances --instance-type z2a.1c2g --count 1 --region-id asia-east-1
```

### Example 4: Use JSON Output Format

```bash
zeno zec describe-instances --output json
```

## Command Hierarchy

The Zenlayer Cloud CLI command hierarchy is as follows:

1. **Root Command**: `zeno`
2. **Service Commands**: such as `zec`, etc.
3. **Operation Commands**: such as `describe-instances`, `create-zec-instances`, etc.

### Command Hierarchy Example

```
zeno
├── configure
├── version
└── zec
    ├── create-zec-instances
    ├── describe-instances
    ├── release-instances
    ├── modify-instances-attribute
    └── start-instances
```

## Global Options

Zenlayer Cloud CLI supports the following global options:

| Option                | Shorthand   | Description                                 |
| --------------------- | ----------- | ------------------------------------------- |
| `--profile`           | `-p`        | Specifies the profile to use                |
| `--output`            | `-o`        | Specifies the output format (json or table) |
| `--query`             | `-q`        | Filters output using JMESPath queries       |
| `--access-key-id`     | <p><br></p> | Specifies the Access Key ID                 |
| `--access-key-secret` | <p><br></p> | Specifies the Access Key Secret             |
| `--debug`             | <p><br></p> | Enables debug mode                          |
| `--help`              | `-h`        | Displays help information                   |

## Command Naming Conventions

Zenlayer Cloud CLI command naming follows these conventions:

* **Service Commands**: Use service abbreviations, such as `zec` (Elastic Compute), etc.
* **Operation Commands**: Use verb+noun format, such as `describe-instances`, `create-zec-instances`, etc.
* **Parameters**: Use lowercase letters and hyphens, such as `--instance-id`, `--instance-type`, etc.

## Command Execution Flow

When you execute a Zenlayer Cloud CLI command, the following flow occurs:

1. The CLI parses the command and parameters
2. Loads configuration (from configuration files or environment variables)
3. Validates credentials
4. Builds the API request
5. Sends the request to the Zenlayer Cloud API
6. Processes the response
7. Outputs the result in the specified format

## Command Best Practices

* **Use Help**: Use the `--help` option to get detailed information about commands
* **Use Auto-Completion**: Set up command auto-completion to improve input efficiency
* **Use Profiles**: Create profiles for different environments for easy switching
* **Use Output Formats**: Choose the appropriate output format based on your needs
* **Use Query Filtering**: Use the `--query` option to filter output and get only the information you need

## FAQ

### Command Not Found

If you get a "command not found" error when running a command, check:

* Whether the CLI is properly installed
* Whether the command is spelled correctly
* Whether the service supports the command

### Parameter Errors

If you encounter parameter errors, check:

* Whether the parameter name is correct
* Whether the parameter value meets requirements
* Whether required parameters are missing


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.console.zenlayer.com/zenlayer-cli/usage/command-structure.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
