Skip to content

23 cli scripts

Zuko edited this page Jan 26, 2026 · 1 revision

CLI Utility Scripts

Project này bao gồm một số scripts Python trong thư mục scripts/ để tự động hóa các tác vụ phát triển thường gặp. Các scripts này thường được gọi thông qua Pixi tasks, nhưng cũng có thể chạy trực tiếp.

1. Generators (generate.py & task_generator.py)

Công cụ để scaffold (tạo khung) nhanh cho các thành phần mới.

Generic Generator

Dùng để tạo Controller, Service, Component.

# Cú pháp
pixi run gen <type> <Name>

# Ví dụ
pixi run gen controller UserProfile  # -> app/controllers/UserProfileController.py
pixi run gen service Authentication  # -> app/services/AuthenticationService.py
pixi run gen component CustomBtn     # -> app/components/CustomBtn.py

Task Generator

Dùng để tạo Task và Step cho hệ thống TaskSystem.

# Tạo Task mới
python scripts/task_generator.py task DataSync --description "Đồng bộ dữ liệu"
# -> services/tasks/DataSyncTask.py

# Tạo Step mới
python scripts/task_generator.py step DownloadFile --description "Tải file từ URL"
# -> services/tasks/steps/DownloadFileStep.py

2. UI Compilation (compile_ui.py)

Script này quét toàn bộ thư mục resources/app/ để biên dịch các file .ui (Qt Designer) và .qrc (Resource) sang file Python.

  • Input: *.ui, *.qrc
  • Output: ui_*.py, *_rc.py
# Chạy qua Pixi (ngắn gọn)
pixi run uic

Lưu ý: Script này nên được chạy mỗi khi bạn sửa đổi giao diện trong Qt Designer. Lệnh pixi run dev đã tự động chạy script này trước khi khởi động app.

3. App Info Configuration (set_app_info.py)

Script tiện ích để cập nhật thông tin ứng dụng (Tên, Version) trong file cấu hình mà không cần sửa code thủ công.

# Cập nhật tên app
python scripts/set_app_info.py --name "My Super App"

# Cập nhật version
python scripts/set_app_info.py --version "1.0.5"

Clone this wiki locally