## ADDED Requirements ### Requirement: Root command and global flags The system SHALL provide a root command `pcli` that serves as the entry point. The root command SHALL register global flags: `--format` (string, default `json`, values `json` or `table`), `--url` (string, overrides `PLANKA_URL`), `--token` (string, overrides `PLANKA_TOKEN`), and `--log-level` (string, default `warn`, values `debug`, `info`, `warn`, `error`). The root command SHALL initialize the logger based on `--log-level` and configure it to write structured JSON to stderr. The root command SHALL validate that URL and token are available (from flags or environment) before executing any subcommand. #### Scenario: Display help - **WHEN** `pcli` is run with no arguments or `--help` - **THEN** the system SHALL display usage information listing all resource subcommands and global flags #### Scenario: Invalid format flag - **WHEN** `--format` is set to an unsupported value - **THEN** the system SHALL print an error and exit with code 1 #### Scenario: Log level controls output - **WHEN** `--log-level=debug` is set - **THEN** DEBUG-level log entries SHALL appear on stderr - **AND** stdout SHALL contain only the command's data output ### Requirement: Project commands The system SHALL provide a `project` command group with subcommands `list` and `get`. `pcli project list` SHALL call the client's ListProjects method and output the result. `pcli project get ` SHALL accept a project ID as a positional argument, call GetProject, and output the result. #### Scenario: List projects - **WHEN** `pcli project list` is executed - **THEN** the system SHALL output all accessible projects #### Scenario: Get project by ID - **WHEN** `pcli project get ` is executed with a valid project ID - **THEN** the system SHALL output the project details #### Scenario: Get project missing ID - **WHEN** `pcli project get` is executed without an ID argument - **THEN** the system SHALL print an error indicating the ID is required and exit with code 1 ### Requirement: Board commands The system SHALL provide a `board` command group with subcommands `get` and `actions`. `pcli board get ` SHALL accept a board ID as a positional argument and output the board details. `pcli board actions ` SHALL accept a board ID and an optional `--limit` flag (int, default 0) and output the board's action history. #### Scenario: Get board - **WHEN** `pcli board get ` is executed - **THEN** the system SHALL output the board details including its lists #### Scenario: List board actions - **WHEN** `pcli board actions ` is executed - **THEN** the system SHALL output the board's action history #### Scenario: List board actions with limit - **WHEN** `pcli board actions --limit 10` is executed - **THEN** the system SHALL output at most 10 action entries ### Requirement: Card commands The system SHALL provide a `card` command group with subcommands: `list`, `get`, `create`, `update`, `delete`, `duplicate`, `move`, `assign`, `unassign`, `add-label`, `remove-label`, `actions`. `pcli card list` SHALL require either `--board ` or `--list ` flag and accept an optional `--limit` flag. `pcli card get ` SHALL accept a card ID as a positional argument. `pcli card create` SHALL require `--list ` and `--name ` flags and accept optional flags: `--description`, `--type`, `--position`, `--due-date`, `--due-completed`. `pcli card update ` SHALL accept a card ID and optional flags for each updatable field: `--name`, `--description`, `--type`, `--position`, `--due-date`, `--due-completed`. `pcli card delete ` SHALL accept a card ID. `pcli card duplicate ` SHALL accept a card ID and optional `--name` and `--position` flags. `pcli card move ` SHALL require `--list ` and accept optional `--position` flag. `pcli card assign ` SHALL require `--user `. `pcli card unassign ` SHALL require `--user `. `pcli card add-label ` SHALL require `--label `. `pcli card remove-label ` SHALL require `--label `. `pcli card actions ` SHALL accept an optional `--limit` flag. #### Scenario: List cards by board - **WHEN** `pcli card list --board ` is executed - **THEN** the system SHALL output all cards across all lists in the board, each enriched with listName #### Scenario: List cards by list - **WHEN** `pcli card list --list ` is executed - **THEN** the system SHALL output cards in the specified list #### Scenario: List cards with limit - **WHEN** `pcli card list --list --limit 5` is executed - **THEN** the system SHALL output at most 5 cards #### Scenario: Card list missing board or list flag - **WHEN** `pcli card list` is executed without `--board` or `--list` - **THEN** the system SHALL print an error indicating one is required and exit with code 1 #### Scenario: Get card - **WHEN** `pcli card get ` is executed - **THEN** the system SHALL output the card details #### Scenario: Create card - **WHEN** `pcli card create --list --name "Task name"` is executed - **THEN** the system SHALL create the card and output the created card #### Scenario: Create card missing required flags - **WHEN** `pcli card create` is executed without `--list` or `--name` - **THEN** the system SHALL print an error and exit with code 1 #### Scenario: Update card - **WHEN** `pcli card update --name "New name"` is executed - **THEN** the system SHALL update the card and output the updated card #### Scenario: Delete card - **WHEN** `pcli card delete ` is executed - **THEN** the system SHALL delete the card and output a success confirmation #### Scenario: Duplicate card - **WHEN** `pcli card duplicate ` is executed - **THEN** the system SHALL duplicate the card and output the new card #### Scenario: Move card - **WHEN** `pcli card move --list ` is executed - **THEN** the system SHALL update the card's listId (and optionally position) and output the updated card #### Scenario: Assign user to card - **WHEN** `pcli card assign --user ` is executed - **THEN** the system SHALL add the user as a card member #### Scenario: Unassign user from card - **WHEN** `pcli card unassign --user ` is executed - **THEN** the system SHALL remove the user from the card's members #### Scenario: Add label to card - **WHEN** `pcli card add-label --label ` is executed - **THEN** the system SHALL add the label to the card #### Scenario: Remove label from card - **WHEN** `pcli card remove-label --label ` is executed - **THEN** the system SHALL remove the label from the card #### Scenario: List card actions - **WHEN** `pcli card actions ` is executed - **THEN** the system SHALL output the card's action history ### Requirement: Comment commands The system SHALL provide a `comment` command group with subcommands: `list`, `create`, `update`, `delete`. `pcli comment list` SHALL require `--card ` and accept optional `--limit`. `pcli comment create` SHALL require `--card ` and `--text `. `pcli comment update ` SHALL require `--text `. `pcli comment delete ` SHALL accept a comment ID. #### Scenario: List comments - **WHEN** `pcli comment list --card ` is executed - **THEN** the system SHALL output comments for the card #### Scenario: Create comment - **WHEN** `pcli comment create --card --text "comment text"` is executed - **THEN** the system SHALL create the comment and output the created comment #### Scenario: Update comment - **WHEN** `pcli comment update --text "updated text"` is executed - **THEN** the system SHALL update the comment and output the updated comment #### Scenario: Delete comment - **WHEN** `pcli comment delete ` is executed - **THEN** the system SHALL delete the comment and output a success confirmation ### Requirement: Task list commands The system SHALL provide a `task-list` command group with subcommands: `create`, `get`, `update`, `delete`. `pcli task-list create` SHALL require `--card ` and `--name ` and accept optional flags: `--position`, `--show-on-front`, `--hide-completed`. `pcli task-list get ` SHALL accept a task list ID. `pcli task-list update ` SHALL accept optional flags for each updatable field. `pcli task-list delete ` SHALL accept a task list ID. #### Scenario: Create task list - **WHEN** `pcli task-list create --card --name "Checklist"` is executed - **THEN** the system SHALL create the task list and output the created task list #### Scenario: Get task list - **WHEN** `pcli task-list get ` is executed - **THEN** the system SHALL output the task list details including its tasks #### Scenario: Update task list - **WHEN** `pcli task-list update --name "Renamed"` is executed - **THEN** the system SHALL update the task list and output the updated task list #### Scenario: Delete task list - **WHEN** `pcli task-list delete ` is executed - **THEN** the system SHALL delete the task list and output a success confirmation ### Requirement: Task commands The system SHALL provide a `task` command group with subcommands: `create`, `update`, `delete`. `pcli task create` SHALL require `--task-list ` and `--name ` and accept optional flags: `--position`, `--completed`, `--assignee`, `--linked-card`. `pcli task update ` SHALL accept optional flags for each updatable field: `--name`, `--position`, `--completed`, `--assignee`, `--task-list`. `pcli task delete ` SHALL accept a task ID. #### Scenario: Create task - **WHEN** `pcli task create --task-list --name "Do something"` is executed - **THEN** the system SHALL create the task and output the created task #### Scenario: Update task - **WHEN** `pcli task update --completed` is executed - **THEN** the system SHALL mark the task as completed and output the updated task #### Scenario: Move task to different list - **WHEN** `pcli task update --task-list ` is executed - **THEN** the system SHALL move the task to the specified task list #### Scenario: Delete task - **WHEN** `pcli task delete ` is executed - **THEN** the system SHALL delete the task and output a success confirmation ### Requirement: Label commands The system SHALL provide a `label` command group with subcommands: `create`, `update`, `delete`. `pcli label create` SHALL require `--board ` and `--name ` and accept optional flags: `--color`, `--position`. `pcli label update ` SHALL accept optional flags: `--name`, `--color`, `--position`. `pcli label delete ` SHALL accept a label ID. #### Scenario: Create label - **WHEN** `pcli label create --board --name "Bug" --color red` is executed - **THEN** the system SHALL create the label and output the created label #### Scenario: Update label - **WHEN** `pcli label update --name "Feature" --color green` is executed - **THEN** the system SHALL update the label and output the updated label #### Scenario: Delete label - **WHEN** `pcli label delete ` is executed - **THEN** the system SHALL delete the label and output a success confirmation