# CLI

> Lệnh browlix — hồ sơ, máy chạy và phiên từ terminal, với đầu ra JSON ổn định và mã thoát rõ ràng.

`browlix` là một file chạy duy nhất cho Windows và Linux. Tải ở [trang tải về](https://browlix.com/download) và kiểm tra SHA-256.

## Đăng nhập

```bash
browlix login        # đọc khoá từ stdin hoặc ô nhập ẩn, không bao giờ từ dòng lệnh
browlix whoami       # workspace của khoá
browlix logout       # quên khoá đã lưu
```

`--api-url` (hoặc `BROWLIX_API_URL`) trỏ CLI sang địa chỉ khác.

## Lệnh hằng ngày

```bash
browlix profiles list --os windows --limit 20
browlix profiles create --name "Shop 01" --os windows
browlix devices list
browlix sessions start --profile <profile-id> --device <device-id> --wait
browlix sessions attach <session-id> --ttl 300
browlix sessions stop <session-id> --wait
browlix receipts get <command-id>
browlix usage
```

`sessions wait <id> --until ready|closed` chỉ chờ; dừng bằng Ctrl+C không bao giờ dừng phiên. `sessions stop` là lệnh duy nhất kết thúc phiên.

## Mọi thao tác

```bash
browlix ops                                   # mọi thao tác máy chủ cung cấp
browlix call profiles.list limit=5 os=linux   # key=value: trường path, query hoặc body
browlix call webhooks.create --body @hook.json
```

Vì `call` đọc danh mục của chính máy chủ, thao tác mới dùng được ngay mà không cần cập nhật CLI.

## Phản hồi

```bash
browlix feedback submit --category docs --summary "sessions attach: say it is loopback-only" \
  --description "Connecting from a CI runner was refused; the help should say where to run." \
  --operation sessions.attach --request-id <correlation_id>
browlix feedback list --status open
browlix feedback get <ticket-id>
browlix feedback comment <ticket-id> "It also happens on Windows."
```

`--description -` và bình luận là `-` đọc nội dung từ stdin. CLI tự ghi tên mình là client; lỗi máy chủ bất ngờ in sẵn gợi ý `feedback submit` kèm correlation id. Khi nào nên gửi: xem [Phản hồi từ agent](https://browlix.com/docs/feedback).

## Viết script

- `--json` in đúng một tài liệu JSON ra stdout, cho cả thành công và lỗi.
- Thao tác ghi in ra `command_id` đã dùng; truyền `--command-id <uuid>` để thử lại đúng lệnh đó.
- `browlix exit-codes` in bảng mã thoát để script rẽ nhánh theo loại lỗi.
