Skip to content

Add support for issue attachments #3

Description

@shbernal

MantisBT supports issue attachments through the REST API, but mantisbt-cli currently only supports issue CRUD and issue notes. It should be possible to attach patch files, screenshots, logs, and other local files to an existing issue from the CLI.

Proposed initial scope:

mantisbt-cli issue file add <issue_id> <path>...
mantisbt-cli issue file list <issue_id>
mantisbt-cli issue file get <issue_id> <file_id> --output <path>

A patch-specific workflow would then compose naturally with Git:

git diff > fix.patch
mantisbt-cli issue file add 1234 fix.patch

Implementation notes:

  • Keep this as generic attachment support rather than a dedicated patch command.
  • Preserve the standard-library-only dependency policy.
  • The MantisBT REST endpoint for adding attachments is POST /api/rest/issues/{issue_id}/files.
  • The upload payload uses JSON with files entries containing a filename and base64-encoded content, so this can fit the existing JSON request style without multipart support.
  • Consider --json behavior for raw API responses and human-readable output for add/list/get.
  • Document the commands in README.md and skills/mantisbt/SKILL.md.

Acceptance criteria:

  • issue file add <issue_id> <path>... uploads one or more files to an existing issue.
  • issue file list <issue_id> lists issue attachments with enough information to select one.
  • issue file get <issue_id> <file_id> --output <path> downloads an attachment to disk.
  • Missing files, invalid output paths, and API errors produce clear CLI errors.
  • Tests cover routing/request bodies and output behavior.
  • go test ./..., go vet ./..., and gofmt pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions