Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default defineConfig({
{ label: 'Memberships', translations: { 'zh-CN': '成员关系' }, slug: 'commands/memberships' },
{ label: 'Versions', translations: { 'zh-CN': '版本' }, slug: 'commands/versions' },
{ label: 'Files', translations: { 'zh-CN': '项目文件' }, slug: 'commands/files' },
{ label: 'Attachments', translations: { 'zh-CN': '附件' }, slug: 'commands/attachments' },
{ label: 'Time Entries', translations: { 'zh-CN': '工时记录' }, slug: 'commands/time' },
{ label: 'Users', translations: { 'zh-CN': '用户' }, slug: 'commands/users' },
{ label: 'My Account', translations: { 'zh-CN': '我的账户' }, slug: 'commands/my_account' },
Expand Down
106 changes: 106 additions & 0 deletions docs/src/content/docs/commands/attachments.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
---
title: Attachments
description: Inspect attachment metadata and download attachment files without curl or manual API-key handling.
---

import { CardGrid, LinkCard, Tabs, TabItem, Aside, Badge } from '@astrojs/starlight/components';

The `attachments` command (aliases `attachment`, `a`) surfaces Redmine's [Attachments API](https://www.redmine.org/projects/redmine/wiki/Rest_api#Attachments) so you can inspect an attachment's metadata and download its bytes. Downloads reuse the active profile's server and API key, streaming straight to disk - no `curl`, no manually extracted key.

<CardGrid>
<LinkCard title="get" href="#get" description="Print attachment metadata (filename, size, type, author)." />
<LinkCard title="download" href="#download" description="Download the file to disk or stream it to stdout." />
</CardGrid>

<Aside type="tip">
Don't know the attachment ID? List an issue's attachments with
[`redmine issues get <id> --attachments`](/commands/issues/#get) - it prints each
attachment's ID, filename, size, and content type.
</Aside>

## get

```bash
redmine attachments get <id> [flags]
```

Aliases: `show`, `view`, `metadata`. Fetches the attachment's ID, filename, size, content type, description, author, and creation time via `GET /attachments/:id.json`. Table output also shows the download URL (when present); `json` returns every field, including `content_url`.

| Flag | Description |
|------|-------------|
| `-o, --output` | Output format: `table`, `json`, `csv` |

<Tabs syncKey="attachments-get">
<TabItem label="Table">
```bash
redmine attachments get 42
```
</TabItem>
<TabItem label="JSON">
```bash
redmine attachments get 42 -o json
```
</TabItem>
<TabItem label="CSV">
```bash
redmine attachments get 42 -o csv
```
</TabItem>
</Tabs>

## download

```bash
redmine attachments download <id> [flags]
```

Aliases: `dl`, `get-file`. Streams the attachment's raw bytes to disk (or stdout), authenticating with the active profile. The response is streamed, never buffered entirely in memory, so large files are safe.

| Flag | Description |
|------|-------------|
| `-d, --dir` | Directory to save into, using the attachment's real filename (created if missing) |
| `--path` | Exact destination file path. Use `-` to stream to stdout |
| `-o, --output` | Confirmation format: `json` prints a result object; otherwise a human line is written to stderr |

With no destination flag, the file is saved as `./<filename>` in the current directory.

<Aside>
Unlike most commands, `-o/--output` here controls only the **confirmation**
output, not where the bytes go - use `--dir` / `--path` for that. When
streaming to stdout (`--path -`), the bytes go to stdout and the confirmation
always goes to stderr, so the pipe stays clean even with `-o json`.
</Aside>

<Tabs syncKey="attachments-download">
<TabItem label="Current dir">
```bash
# Saves ./<filename>
redmine attachments download 42
```
</TabItem>
<TabItem label="Into a directory">
```bash
redmine attachments download 42 --dir ./downloads
```
</TabItem>
<TabItem label="Exact path">
```bash
redmine attachments download 42 --path ./logo.png
```
</TabItem>
<TabItem label="Pipe to stdout">
```bash
redmine attachments download 42 --path - | file -
```
</TabItem>
<TabItem label="JSON result">
```bash
redmine attachments download 42 --dir ./downloads -o json
```
</TabItem>
</Tabs>

<Aside type="tip">
To grab **every** attachment of an issue in one step, use
[`redmine issues get <id> --download-attachments <dir>`](/commands/issues/#get).
</Aside>
33 changes: 28 additions & 5 deletions docs/src/content/docs/commands/issues.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,34 @@ Aliases: `show`, `view`.

| Flag | Description |
|------|-------------|
| `--include` | Include related data: `journals`, `children`, `relations` |
| `--journals` | Shorthand for `--include journals` |
| `--children` | Shorthand for `--include children` |
| `--relations` | Shorthand for `--include relations` |
| `-o, --output` | Output format |
| `--include` | Include related data: `journals`, `children`, `relations`, `attachments` |
| `--journals` | Shorthand for `--include journals` |
| `--children` | Shorthand for `--include children` |
| `--relations` | Shorthand for `--include relations` |
| `--attachments` | List the issue's attachments (id, filename, size, content type) |
| `--download-attachments` | Download every attachment of the issue into the given directory |
| `-o, --output` | Output format |

<Tabs syncKey="issues-get">
<TabItem label="Attachments">
```bash
# List attachment IDs so you can download one
redmine issues get 123 --attachments
```
</TabItem>
<TabItem label="Download all">
```bash
# Pull every attachment into ./issue-123
redmine issues get 123 --download-attachments ./issue-123
```
</TabItem>
</Tabs>

<Aside type="tip">
`--attachments` surfaces each attachment's ID. Feed that ID to
[`attachments download <id>`](/commands/attachments/#download) to fetch a single
file, or use `--download-attachments <dir>` to grab them all at once.
</Aside>

## create

Expand Down
105 changes: 105 additions & 0 deletions docs/src/content/docs/zh-cn/commands/attachments.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
title: 附件
description: 查看附件元数据并下载附件文件,无需 curl,也无需手动处理 API 密钥。
---

import { CardGrid, LinkCard, Tabs, TabItem, Aside, Badge } from '@astrojs/starlight/components';

`attachments` 命令(别名 `attachment`、`a`)封装了 Redmine 的[附件 API](https://www.redmine.org/projects/redmine/wiki/Rest_api#Attachments),让你既能查看附件的元数据,也能下载其字节内容。下载会复用当前 profile 的服务器地址和 API 密钥,并直接流式写入磁盘 - 无需 `curl`,也无需手动提取密钥。

<CardGrid>
<LinkCard title="get" href="#get" description="打印附件元数据(文件名、大小、类型、作者)。" />
<LinkCard title="download" href="#download" description="将文件下载到磁盘,或流式输出到 stdout。" />
</CardGrid>

<Aside type="tip">
不知道附件 ID?用
[`redmine issues get <id> --attachments`](/zh-cn/commands/issues/#get)
列出工单的附件 - 它会打印每个附件的 ID、文件名、大小和内容类型。
</Aside>

## get

```bash
redmine attachments get <id> [flags]
```

别名:`show`、`view`、`metadata`。通过 `GET /attachments/:id.json` 获取附件的 ID、文件名、大小、内容类型、描述、作者和创建时间。表格输出还会显示下载 URL(若存在);`json` 会返回所有字段,包括 `content_url`。

| 标志 | 描述 |
|------|------|
| `-o, --output` | 输出格式:`table`、`json`、`csv` |

<Tabs syncKey="attachments-get">
<TabItem label="表格">
```bash
redmine attachments get 42
```
</TabItem>
<TabItem label="JSON">
```bash
redmine attachments get 42 -o json
```
</TabItem>
<TabItem label="CSV">
```bash
redmine attachments get 42 -o csv
```
</TabItem>
</Tabs>

## download

```bash
redmine attachments download <id> [flags]
```

别名:`dl`、`get-file`。使用当前 profile 进行认证,将附件的原始字节流式写入磁盘(或 stdout)。响应是流式处理的,不会整体缓存在内存中,因此下载大文件也很安全。

| 标志 | 描述 |
|------|------|
| `-d, --dir` | 保存到的目录,使用附件的真实文件名(目录不存在时自动创建) |
| `--path` | 精确的目标文件路径。使用 `-` 可流式输出到 stdout |
| `-o, --output` | 确认信息的格式:`json` 打印结果对象;否则向 stderr 写入一行可读信息 |

若不指定目标标志,文件会以 `./<文件名>` 保存到当前目录。

<Aside>
与大多数命令不同,这里的 `-o/--output` 仅控制**确认信息**的输出,而不决定字节写到哪里 -
请用 `--dir` / `--path` 来指定目标。当流式输出到 stdout(`--path -`)时,字节写入 stdout,
确认信息始终写入 stderr,因此即便加上 `-o json`,管道内容也不会被污染。
</Aside>

<Tabs syncKey="attachments-download">
<TabItem label="当前目录">
```bash
# 保存为 ./<文件名>
redmine attachments download 42
```
</TabItem>
<TabItem label="保存到目录">
```bash
redmine attachments download 42 --dir ./downloads
```
</TabItem>
<TabItem label="精确路径">
```bash
redmine attachments download 42 --path ./logo.png
```
</TabItem>
<TabItem label="管道到 stdout">
```bash
redmine attachments download 42 --path - | file -
```
</TabItem>
<TabItem label="JSON 结果">
```bash
redmine attachments download 42 --dir ./downloads -o json
```
</TabItem>
</Tabs>

<Aside type="tip">
若要一次性获取某个工单的**所有**附件,请使用
[`redmine issues get <id> --download-attachments <dir>`](/zh-cn/commands/issues/#get)。
</Aside>
33 changes: 28 additions & 5 deletions docs/src/content/docs/zh-cn/commands/issues.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,34 @@ redmine issues get <id> [flags]

| 标志 | 描述 |
|------|------|
| `--include` | 包含关联数据:`journals`、`children`、`relations` |
| `--journals` | `--include journals` 的简写 |
| `--children` | `--include children` 的简写 |
| `--relations` | `--include relations` 的简写 |
| `-o, --output` | 输出格式 |
| `--include` | 包含关联数据:`journals`、`children`、`relations`、`attachments` |
| `--journals` | `--include journals` 的简写 |
| `--children` | `--include children` 的简写 |
| `--relations` | `--include relations` 的简写 |
| `--attachments` | 列出工单的附件(id、文件名、大小、内容类型) |
| `--download-attachments` | 将工单的所有附件下载到指定目录 |
| `-o, --output` | 输出格式 |

<Tabs syncKey="issues-get">
<TabItem label="附件">
```bash
# 列出附件 ID,以便下载某个附件
redmine issues get 123 --attachments
```
</TabItem>
<TabItem label="全部下载">
```bash
# 将所有附件下载到 ./issue-123
redmine issues get 123 --download-attachments ./issue-123
```
</TabItem>
</Tabs>

<Aside type="tip">
`--attachments` 会显示每个附件的 ID。把该 ID 传给
[`attachments download <id>`](/zh-cn/commands/attachments/#download) 可下载单个文件,
或使用 `--download-attachments <dir>` 一次性下载全部附件。
</Aside>

## create

Expand Down
Loading