Parse command-line arguments. Args: argv: Raw command-line arguments excluding the executable name. Returns: Parsed CLI arguments. Raises: ReleaseError: Push is requested without commit.
(argv: list[str])
| 381 | |
| 382 | |
| 383 | def parse_args(argv: list[str]) -> argparse.Namespace: |
| 384 | """Parse command-line arguments. |
| 385 | |
| 386 | Args: |
| 387 | argv: Raw command-line arguments excluding the executable name. |
| 388 | |
| 389 | Returns: |
| 390 | Parsed CLI arguments. |
| 391 | |
| 392 | Raises: |
| 393 | ReleaseError: Push is requested without commit. |
| 394 | """ |
| 395 | parser = argparse.ArgumentParser( |
| 396 | description="Prepare an AstrBot release branch, version bump, and changelog.", |
| 397 | ) |
| 398 | parser.add_argument("version", help="Release version without the leading v") |
| 399 | parser.add_argument("--base-branch", default="master", help="Release base branch") |
| 400 | parser.add_argument("--remote", default="origin", help="Git remote name") |
| 401 | parser.add_argument( |
| 402 | "--generate-api-client", |
| 403 | action="store_true", |
| 404 | help="Run dashboard API client generation before validation", |
| 405 | ) |
| 406 | parser.add_argument( |
| 407 | "--dashboard-build", |
| 408 | action="store_true", |
| 409 | help="Run dashboard install and build validation", |
| 410 | ) |
| 411 | parser.add_argument( |
| 412 | "--skip-checks", |
| 413 | action="store_true", |
| 414 | help="Skip ruff format and ruff check", |
| 415 | ) |
| 416 | parser.add_argument( |
| 417 | "--commit", |
| 418 | action="store_true", |
| 419 | help="Commit the generated release preparation changes", |
| 420 | ) |
| 421 | parser.add_argument( |
| 422 | "--push", |
| 423 | action="store_true", |
| 424 | help="Push the release branch after committing; requires --commit", |
| 425 | ) |
| 426 | args = parser.parse_args(argv) |
| 427 | if args.push and not args.commit: |
| 428 | raise ReleaseError("--push requires --commit") |
| 429 | return args |
| 430 | |
| 431 | |
| 432 | def main(argv: list[str] | None = None) -> int: |