artdam-cli 0.2.0__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/PKG-INFO +66 -31
  2. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/README.md +65 -30
  3. artdam_cli-0.2.1/artdam_cli/__init__.py +1 -0
  4. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli/commands/project.py +28 -28
  5. artdam_cli-0.2.1/artdam_cli/commands/projects.py +41 -0
  6. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli/main.py +2 -0
  7. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli.egg-info/PKG-INFO +66 -31
  8. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli.egg-info/SOURCES.txt +1 -0
  9. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/pyproject.toml +1 -1
  10. artdam_cli-0.2.0/artdam_cli/__init__.py +0 -1
  11. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli/client.py +0 -0
  12. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli/commands/__init__.py +0 -0
  13. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli/commands/comment.py +0 -0
  14. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli/commands/delete_cmd.py +0 -0
  15. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli/commands/download.py +0 -0
  16. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli/commands/favorite.py +0 -0
  17. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli/commands/folder_cmd.py +0 -0
  18. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli/commands/folders.py +0 -0
  19. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli/commands/get.py +0 -0
  20. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli/commands/login.py +0 -0
  21. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli/commands/rate.py +0 -0
  22. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli/commands/restore.py +0 -0
  23. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli/commands/search.py +0 -0
  24. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli/commands/tag_cmd.py +0 -0
  25. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli/commands/tags.py +0 -0
  26. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli/commands/update.py +0 -0
  27. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli/commands/upload.py +0 -0
  28. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli/config.py +0 -0
  29. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli.egg-info/dependency_links.txt +0 -0
  30. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli.egg-info/entry_points.txt +0 -0
  31. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli.egg-info/requires.txt +0 -0
  32. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/artdam_cli.egg-info/top_level.txt +0 -0
  33. {artdam_cli-0.2.0 → artdam_cli-0.2.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: artdam-cli
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: ArtDAM 数字资产管理平台命令行工具
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -28,8 +28,14 @@ pip install artdam-cli
28
28
  # 登录(首次使用,服务器地址已内置)
29
29
  artdam login --username <用户名> --password <密码>
30
30
 
31
+ # 查看可访问的项目列表(获取项目 ID)
32
+ artdam projects
33
+
34
+ # 设置默认项目(之后无需每次输入 -p)
35
+ artdam project use 1
36
+
31
37
  # 搜索资产
32
- artdam search "关键词" --project 1
38
+ artdam search "关键词"
33
39
 
34
40
  # 查看资产详情
35
41
  artdam get 123
@@ -42,6 +48,24 @@ artdam download 123 --out ./downloads
42
48
 
43
49
  ### 查询命令(viewer 及以上)
44
50
 
51
+ #### `artdam projects`
52
+
53
+ 列出当前用户可访问的所有项目(含 ID)。
54
+
55
+ ```bash
56
+ artdam projects
57
+ artdam projects --json # 输出原始 JSON(AI Agent 用)
58
+ ```
59
+
60
+ #### `artdam project use / show`
61
+
62
+ 设置或查看默认项目,设置后所有命令无需再传 `-p`。
63
+
64
+ ```bash
65
+ artdam project use 1 # 设置默认项目 ID 为 1
66
+ artdam project show # 查看当前默认项目
67
+ ```
68
+
45
69
  #### `artdam login`
46
70
 
47
71
  登录 ArtDAM,保存 token 到本地 `~/.artdam/config.json`。
@@ -55,17 +79,18 @@ artdam login --username <用户名> --password <密码>
55
79
  搜索资产,返回匹配列表。
56
80
 
57
81
  ```bash
58
- artdam search "头盔" --project 1
59
- artdam search "头盔" --project 1 --limit 50
60
- artdam search "头盔" --project 1 --type image/png
61
- artdam search "头盔" --project 1 --folder 10
62
- artdam search "头盔" --project 1 --json # 输出原始 JSON(AI Agent 用)
82
+ artdam search "头盔" # 使用默认项目
83
+ artdam search "头盔" --project 1 # 临时指定项目
84
+ artdam search "头盔" --limit 50
85
+ artdam search "头盔" --type image/png
86
+ artdam search "头盔" --folder 10
87
+ artdam search "头盔" --json # 输出原始 JSON(AI Agent 用)
63
88
  ```
64
89
 
65
90
  | 参数 | 说明 |
66
91
  |---|---|
67
92
  | `KEYWORD` | 搜索关键词 |
68
- | `-p, --project` | 项目 ID(必填) |
93
+ | `-p, --project` | 项目 ID(省略则使用默认项目) |
69
94
  | `-n, --limit` | 返回数量上限(默认 20) |
70
95
  | `--type` | 文件类型,如 `image/png` |
71
96
  | `--folder` | 限定文件夹 ID |
@@ -94,9 +119,9 @@ artdam download 123 --out ./downloads
94
119
  列出项目标签。
95
120
 
96
121
  ```bash
97
- artdam tags --project 1
98
- artdam tags --project 1 --search "角色"
99
- artdam tags --project 1 --json
122
+ artdam tags # 使用默认项目
123
+ artdam tags --search "角色"
124
+ artdam tags --json
100
125
  ```
101
126
 
102
127
  #### `artdam folders`
@@ -104,8 +129,8 @@ artdam tags --project 1 --json
104
129
  查看文件夹结构。
105
130
 
106
131
  ```bash
107
- artdam folders --project 1
108
- artdam folders --project 1 --json
132
+ artdam folders # 使用默认项目
133
+ artdam folders --json
109
134
  ```
110
135
 
111
136
  ### 资产管理(member 及以上)
@@ -115,8 +140,9 @@ artdam folders --project 1 --json
115
140
  上传文件到指定项目和文件夹。
116
141
 
117
142
  ```bash
118
- artdam upload ./image.jpg --project 1
119
- artdam upload ./image.jpg --project 1 --folder 10
143
+ artdam upload ./image.jpg # 使用默认项目
144
+ artdam upload ./image.jpg --folder 10
145
+ artdam upload ./image.jpg --project 1 # 临时指定项目
120
146
  ```
121
147
 
122
148
  #### `artdam update`
@@ -154,16 +180,17 @@ artdam tag add 123 5
154
180
  # 从资产移除标签
155
181
  artdam tag remove 123 5
156
182
 
157
- # 创建新标签
183
+ # 创建新标签(省略 -p 则使用默认项目)
184
+ artdam tag create "标签名"
158
185
  artdam tag create "标签名" --project 1
159
186
  ```
160
187
 
161
188
  ### 文件夹管理(member 及以上)
162
189
 
163
190
  ```bash
164
- # 创建文件夹
165
- artdam folder create "文件夹名" --project 1
166
- artdam folder create "子文件夹" --project 1 --parent 10
191
+ # 创建文件夹(省略 -p 则使用默认项目)
192
+ artdam folder create "文件夹名"
193
+ artdam folder create "子文件夹" --parent 10
167
194
 
168
195
  # 删除文件夹
169
196
  artdam folder delete 10
@@ -188,36 +215,43 @@ artdam favorite 123 --remove
188
215
  所有查询命令支持 `--json` 输出原始 JSON,适合 Agent 解析:
189
216
 
190
217
  ```bash
191
- artdam search "安妮" --project 1 --json
218
+ artdam projects --json
219
+ artdam search "安妮" --json
192
220
  artdam get 123 --json
193
- artdam tags --project 1 --json
194
- artdam folders --project 1 --json
221
+ artdam tags --json
222
+ artdam folders --json
195
223
  ```
196
224
 
197
225
  ### 典型 Agent 工作流
198
226
 
199
227
  ```bash
200
- # 1. 登录(向用户获取用户名密码后执行)
228
+ # 1. 登录
201
229
  artdam login --username <用户名> --password <密码>
202
230
 
203
- # 2. 搜索 → 确认 → 下载
204
- artdam search "头盔" --project 1 --json
231
+ # 2. 查询项目列表,选择目标项目并设为默认
232
+ artdam projects --json
233
+ artdam project use 1
234
+
235
+ # 3. 搜索 → 确认 → 下载
236
+ artdam search "头盔" --json
205
237
  artdam get 50707 --json
206
238
  artdam download 50707 --out ./assets
207
239
 
208
- # 3. 搜索 → 批量打标签
209
- artdam search "安妮" --project 1 --json
240
+ # 4. 搜索 → 批量打标签
241
+ artdam search "安妮" --json
210
242
  artdam tag add 50707 5
211
243
  artdam tag add 50708 5
212
244
 
213
- # 4. 上传并更新描述
214
- artdam upload ./new_asset.jpg --project 1 --folder 10
245
+ # 5. 上传并更新描述
246
+ artdam upload ./new_asset.jpg --folder 10
215
247
  artdam update <asset_id> --description "AI 生成的场景描述"
216
248
  ```
217
249
 
218
250
  ## 注意事项
219
251
 
220
- - `--project` 参数为**数字 ID**,不是项目名称
252
+ - 首次使用先运行 `artdam projects` 获取项目 ID,再 `artdam project use <id>` 设置默认项目
253
+ - 设置默认项目后,`search` / `tags` / `folders` / `upload` 等命令无需再传 `-p`
254
+ - `-p` 仍可临时覆盖默认项目
221
255
  - `--json` 返回原始 JSON,适合程序解析
222
256
  - token 保存在 `~/.artdam/config.json`,登录一次长期有效
223
257
  - `artdam delete` 是软删除,可用 `artdam restore` 恢复
@@ -230,6 +264,7 @@ artdam update <asset_id> --description "AI 生成的场景描述"
230
264
  ```json
231
265
  {
232
266
  "base_url": "https://artdam.dsworks.cn",
233
- "token": "eyJ..."
267
+ "token": "eyJ...",
268
+ "default_project": 1
234
269
  }
235
270
  ```
@@ -18,8 +18,14 @@ pip install artdam-cli
18
18
  # 登录(首次使用,服务器地址已内置)
19
19
  artdam login --username <用户名> --password <密码>
20
20
 
21
+ # 查看可访问的项目列表(获取项目 ID)
22
+ artdam projects
23
+
24
+ # 设置默认项目(之后无需每次输入 -p)
25
+ artdam project use 1
26
+
21
27
  # 搜索资产
22
- artdam search "关键词" --project 1
28
+ artdam search "关键词"
23
29
 
24
30
  # 查看资产详情
25
31
  artdam get 123
@@ -32,6 +38,24 @@ artdam download 123 --out ./downloads
32
38
 
33
39
  ### 查询命令(viewer 及以上)
34
40
 
41
+ #### `artdam projects`
42
+
43
+ 列出当前用户可访问的所有项目(含 ID)。
44
+
45
+ ```bash
46
+ artdam projects
47
+ artdam projects --json # 输出原始 JSON(AI Agent 用)
48
+ ```
49
+
50
+ #### `artdam project use / show`
51
+
52
+ 设置或查看默认项目,设置后所有命令无需再传 `-p`。
53
+
54
+ ```bash
55
+ artdam project use 1 # 设置默认项目 ID 为 1
56
+ artdam project show # 查看当前默认项目
57
+ ```
58
+
35
59
  #### `artdam login`
36
60
 
37
61
  登录 ArtDAM,保存 token 到本地 `~/.artdam/config.json`。
@@ -45,17 +69,18 @@ artdam login --username <用户名> --password <密码>
45
69
  搜索资产,返回匹配列表。
46
70
 
47
71
  ```bash
48
- artdam search "头盔" --project 1
49
- artdam search "头盔" --project 1 --limit 50
50
- artdam search "头盔" --project 1 --type image/png
51
- artdam search "头盔" --project 1 --folder 10
52
- artdam search "头盔" --project 1 --json # 输出原始 JSON(AI Agent 用)
72
+ artdam search "头盔" # 使用默认项目
73
+ artdam search "头盔" --project 1 # 临时指定项目
74
+ artdam search "头盔" --limit 50
75
+ artdam search "头盔" --type image/png
76
+ artdam search "头盔" --folder 10
77
+ artdam search "头盔" --json # 输出原始 JSON(AI Agent 用)
53
78
  ```
54
79
 
55
80
  | 参数 | 说明 |
56
81
  |---|---|
57
82
  | `KEYWORD` | 搜索关键词 |
58
- | `-p, --project` | 项目 ID(必填) |
83
+ | `-p, --project` | 项目 ID(省略则使用默认项目) |
59
84
  | `-n, --limit` | 返回数量上限(默认 20) |
60
85
  | `--type` | 文件类型,如 `image/png` |
61
86
  | `--folder` | 限定文件夹 ID |
@@ -84,9 +109,9 @@ artdam download 123 --out ./downloads
84
109
  列出项目标签。
85
110
 
86
111
  ```bash
87
- artdam tags --project 1
88
- artdam tags --project 1 --search "角色"
89
- artdam tags --project 1 --json
112
+ artdam tags # 使用默认项目
113
+ artdam tags --search "角色"
114
+ artdam tags --json
90
115
  ```
91
116
 
92
117
  #### `artdam folders`
@@ -94,8 +119,8 @@ artdam tags --project 1 --json
94
119
  查看文件夹结构。
95
120
 
96
121
  ```bash
97
- artdam folders --project 1
98
- artdam folders --project 1 --json
122
+ artdam folders # 使用默认项目
123
+ artdam folders --json
99
124
  ```
100
125
 
101
126
  ### 资产管理(member 及以上)
@@ -105,8 +130,9 @@ artdam folders --project 1 --json
105
130
  上传文件到指定项目和文件夹。
106
131
 
107
132
  ```bash
108
- artdam upload ./image.jpg --project 1
109
- artdam upload ./image.jpg --project 1 --folder 10
133
+ artdam upload ./image.jpg # 使用默认项目
134
+ artdam upload ./image.jpg --folder 10
135
+ artdam upload ./image.jpg --project 1 # 临时指定项目
110
136
  ```
111
137
 
112
138
  #### `artdam update`
@@ -144,16 +170,17 @@ artdam tag add 123 5
144
170
  # 从资产移除标签
145
171
  artdam tag remove 123 5
146
172
 
147
- # 创建新标签
173
+ # 创建新标签(省略 -p 则使用默认项目)
174
+ artdam tag create "标签名"
148
175
  artdam tag create "标签名" --project 1
149
176
  ```
150
177
 
151
178
  ### 文件夹管理(member 及以上)
152
179
 
153
180
  ```bash
154
- # 创建文件夹
155
- artdam folder create "文件夹名" --project 1
156
- artdam folder create "子文件夹" --project 1 --parent 10
181
+ # 创建文件夹(省略 -p 则使用默认项目)
182
+ artdam folder create "文件夹名"
183
+ artdam folder create "子文件夹" --parent 10
157
184
 
158
185
  # 删除文件夹
159
186
  artdam folder delete 10
@@ -178,36 +205,43 @@ artdam favorite 123 --remove
178
205
  所有查询命令支持 `--json` 输出原始 JSON,适合 Agent 解析:
179
206
 
180
207
  ```bash
181
- artdam search "安妮" --project 1 --json
208
+ artdam projects --json
209
+ artdam search "安妮" --json
182
210
  artdam get 123 --json
183
- artdam tags --project 1 --json
184
- artdam folders --project 1 --json
211
+ artdam tags --json
212
+ artdam folders --json
185
213
  ```
186
214
 
187
215
  ### 典型 Agent 工作流
188
216
 
189
217
  ```bash
190
- # 1. 登录(向用户获取用户名密码后执行)
218
+ # 1. 登录
191
219
  artdam login --username <用户名> --password <密码>
192
220
 
193
- # 2. 搜索 → 确认 → 下载
194
- artdam search "头盔" --project 1 --json
221
+ # 2. 查询项目列表,选择目标项目并设为默认
222
+ artdam projects --json
223
+ artdam project use 1
224
+
225
+ # 3. 搜索 → 确认 → 下载
226
+ artdam search "头盔" --json
195
227
  artdam get 50707 --json
196
228
  artdam download 50707 --out ./assets
197
229
 
198
- # 3. 搜索 → 批量打标签
199
- artdam search "安妮" --project 1 --json
230
+ # 4. 搜索 → 批量打标签
231
+ artdam search "安妮" --json
200
232
  artdam tag add 50707 5
201
233
  artdam tag add 50708 5
202
234
 
203
- # 4. 上传并更新描述
204
- artdam upload ./new_asset.jpg --project 1 --folder 10
235
+ # 5. 上传并更新描述
236
+ artdam upload ./new_asset.jpg --folder 10
205
237
  artdam update <asset_id> --description "AI 生成的场景描述"
206
238
  ```
207
239
 
208
240
  ## 注意事项
209
241
 
210
- - `--project` 参数为**数字 ID**,不是项目名称
242
+ - 首次使用先运行 `artdam projects` 获取项目 ID,再 `artdam project use <id>` 设置默认项目
243
+ - 设置默认项目后,`search` / `tags` / `folders` / `upload` 等命令无需再传 `-p`
244
+ - `-p` 仍可临时覆盖默认项目
211
245
  - `--json` 返回原始 JSON,适合程序解析
212
246
  - token 保存在 `~/.artdam/config.json`,登录一次长期有效
213
247
  - `artdam delete` 是软删除,可用 `artdam restore` 恢复
@@ -220,6 +254,7 @@ artdam update <asset_id> --description "AI 生成的场景描述"
220
254
  ```json
221
255
  {
222
256
  "base_url": "https://artdam.dsworks.cn",
223
- "token": "eyJ..."
257
+ "token": "eyJ...",
258
+ "default_project": 1
224
259
  }
225
260
  ```
@@ -0,0 +1 @@
1
+ __version__ = "0.2.1"
@@ -1,28 +1,28 @@
1
- import click
2
-
3
- from artdam_cli import config
4
-
5
-
6
- @click.group(name="project")
7
- def project_group() -> None:
8
- """管理默认项目(省去每次输入 -p)。"""
9
-
10
-
11
- @project_group.command(name="use")
12
- @click.argument("project_id", type=int)
13
- def project_use(project_id: int) -> None:
14
- """设置默认项目 ID。"""
15
- data = config.load()
16
- data["default_project"] = project_id
17
- config.save(data)
18
- click.echo(f"✓ 默认项目已设置为 {project_id}")
19
-
20
-
21
- @project_group.command(name="show")
22
- def project_show() -> None:
23
- """查看当前默认项目。"""
24
- pid = config.get("default_project")
25
- if pid is None:
26
- click.echo("未设置默认项目,运行: artdam project use <id>")
27
- else:
28
- click.echo(f"默认项目: {pid}")
1
+ import click
2
+
3
+ from artdam_cli import config
4
+
5
+
6
+ @click.group(name="project")
7
+ def project_group() -> None:
8
+ """管理默认项目(省去每次输入 -p)。"""
9
+
10
+
11
+ @project_group.command(name="use")
12
+ @click.argument("project_id", type=int)
13
+ def project_use(project_id: int) -> None:
14
+ """设置默认项目 ID。"""
15
+ data = config.load()
16
+ data["default_project"] = project_id
17
+ config.save(data)
18
+ click.echo(f"✓ 默认项目已设置为 {project_id}")
19
+
20
+
21
+ @project_group.command(name="show")
22
+ def project_show() -> None:
23
+ """查看当前默认项目。"""
24
+ pid = config.get("default_project")
25
+ if pid is None:
26
+ click.echo("未设置默认项目,运行: artdam project use <id>")
27
+ else:
28
+ click.echo(f"默认项目: {pid}")
@@ -0,0 +1,41 @@
1
+ import json
2
+
3
+ import click
4
+ from rich.console import Console
5
+ from rich.table import Table
6
+
7
+ from artdam_cli import client
8
+
9
+ console = Console()
10
+
11
+
12
+ @click.command()
13
+ @click.option("--json", "as_json", is_flag=True, help="输出原始 JSON(AI Agent 用)")
14
+ def projects(as_json: bool) -> None:
15
+ """列出当前用户可访问的所有项目。"""
16
+ data = client.get("/api/projects/")
17
+ items = data if isinstance(data, list) else []
18
+
19
+ if as_json:
20
+ click.echo(json.dumps(items, ensure_ascii=False, indent=2))
21
+ return
22
+
23
+ if not items:
24
+ console.print("[yellow]暂无可访问的项目[/yellow]")
25
+ return
26
+
27
+ table = Table(title=f"项目列表(共 {len(items)} 个)")
28
+ table.add_column("ID", style="dim", width=6)
29
+ table.add_column("代码", width=10)
30
+ table.add_column("名称", min_width=16)
31
+ table.add_column("描述", min_width=20)
32
+
33
+ for item in items:
34
+ table.add_row(
35
+ str(item["id"]),
36
+ item.get("code", ""),
37
+ item.get("name", ""),
38
+ item.get("description") or "—",
39
+ )
40
+
41
+ console.print(table)
@@ -16,6 +16,7 @@ from artdam_cli.commands.comment import comment
16
16
  from artdam_cli.commands.rate import rate
17
17
  from artdam_cli.commands.favorite import favorite
18
18
  from artdam_cli.commands.project import project_group
19
+ from artdam_cli.commands.projects import projects
19
20
 
20
21
 
21
22
  @click.group()
@@ -40,3 +41,4 @@ cli.add_command(comment)
40
41
  cli.add_command(rate)
41
42
  cli.add_command(favorite)
42
43
  cli.add_command(project_group)
44
+ cli.add_command(projects)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: artdam-cli
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: ArtDAM 数字资产管理平台命令行工具
5
5
  Requires-Python: >=3.10
6
6
  Description-Content-Type: text/markdown
@@ -28,8 +28,14 @@ pip install artdam-cli
28
28
  # 登录(首次使用,服务器地址已内置)
29
29
  artdam login --username <用户名> --password <密码>
30
30
 
31
+ # 查看可访问的项目列表(获取项目 ID)
32
+ artdam projects
33
+
34
+ # 设置默认项目(之后无需每次输入 -p)
35
+ artdam project use 1
36
+
31
37
  # 搜索资产
32
- artdam search "关键词" --project 1
38
+ artdam search "关键词"
33
39
 
34
40
  # 查看资产详情
35
41
  artdam get 123
@@ -42,6 +48,24 @@ artdam download 123 --out ./downloads
42
48
 
43
49
  ### 查询命令(viewer 及以上)
44
50
 
51
+ #### `artdam projects`
52
+
53
+ 列出当前用户可访问的所有项目(含 ID)。
54
+
55
+ ```bash
56
+ artdam projects
57
+ artdam projects --json # 输出原始 JSON(AI Agent 用)
58
+ ```
59
+
60
+ #### `artdam project use / show`
61
+
62
+ 设置或查看默认项目,设置后所有命令无需再传 `-p`。
63
+
64
+ ```bash
65
+ artdam project use 1 # 设置默认项目 ID 为 1
66
+ artdam project show # 查看当前默认项目
67
+ ```
68
+
45
69
  #### `artdam login`
46
70
 
47
71
  登录 ArtDAM,保存 token 到本地 `~/.artdam/config.json`。
@@ -55,17 +79,18 @@ artdam login --username <用户名> --password <密码>
55
79
  搜索资产,返回匹配列表。
56
80
 
57
81
  ```bash
58
- artdam search "头盔" --project 1
59
- artdam search "头盔" --project 1 --limit 50
60
- artdam search "头盔" --project 1 --type image/png
61
- artdam search "头盔" --project 1 --folder 10
62
- artdam search "头盔" --project 1 --json # 输出原始 JSON(AI Agent 用)
82
+ artdam search "头盔" # 使用默认项目
83
+ artdam search "头盔" --project 1 # 临时指定项目
84
+ artdam search "头盔" --limit 50
85
+ artdam search "头盔" --type image/png
86
+ artdam search "头盔" --folder 10
87
+ artdam search "头盔" --json # 输出原始 JSON(AI Agent 用)
63
88
  ```
64
89
 
65
90
  | 参数 | 说明 |
66
91
  |---|---|
67
92
  | `KEYWORD` | 搜索关键词 |
68
- | `-p, --project` | 项目 ID(必填) |
93
+ | `-p, --project` | 项目 ID(省略则使用默认项目) |
69
94
  | `-n, --limit` | 返回数量上限(默认 20) |
70
95
  | `--type` | 文件类型,如 `image/png` |
71
96
  | `--folder` | 限定文件夹 ID |
@@ -94,9 +119,9 @@ artdam download 123 --out ./downloads
94
119
  列出项目标签。
95
120
 
96
121
  ```bash
97
- artdam tags --project 1
98
- artdam tags --project 1 --search "角色"
99
- artdam tags --project 1 --json
122
+ artdam tags # 使用默认项目
123
+ artdam tags --search "角色"
124
+ artdam tags --json
100
125
  ```
101
126
 
102
127
  #### `artdam folders`
@@ -104,8 +129,8 @@ artdam tags --project 1 --json
104
129
  查看文件夹结构。
105
130
 
106
131
  ```bash
107
- artdam folders --project 1
108
- artdam folders --project 1 --json
132
+ artdam folders # 使用默认项目
133
+ artdam folders --json
109
134
  ```
110
135
 
111
136
  ### 资产管理(member 及以上)
@@ -115,8 +140,9 @@ artdam folders --project 1 --json
115
140
  上传文件到指定项目和文件夹。
116
141
 
117
142
  ```bash
118
- artdam upload ./image.jpg --project 1
119
- artdam upload ./image.jpg --project 1 --folder 10
143
+ artdam upload ./image.jpg # 使用默认项目
144
+ artdam upload ./image.jpg --folder 10
145
+ artdam upload ./image.jpg --project 1 # 临时指定项目
120
146
  ```
121
147
 
122
148
  #### `artdam update`
@@ -154,16 +180,17 @@ artdam tag add 123 5
154
180
  # 从资产移除标签
155
181
  artdam tag remove 123 5
156
182
 
157
- # 创建新标签
183
+ # 创建新标签(省略 -p 则使用默认项目)
184
+ artdam tag create "标签名"
158
185
  artdam tag create "标签名" --project 1
159
186
  ```
160
187
 
161
188
  ### 文件夹管理(member 及以上)
162
189
 
163
190
  ```bash
164
- # 创建文件夹
165
- artdam folder create "文件夹名" --project 1
166
- artdam folder create "子文件夹" --project 1 --parent 10
191
+ # 创建文件夹(省略 -p 则使用默认项目)
192
+ artdam folder create "文件夹名"
193
+ artdam folder create "子文件夹" --parent 10
167
194
 
168
195
  # 删除文件夹
169
196
  artdam folder delete 10
@@ -188,36 +215,43 @@ artdam favorite 123 --remove
188
215
  所有查询命令支持 `--json` 输出原始 JSON,适合 Agent 解析:
189
216
 
190
217
  ```bash
191
- artdam search "安妮" --project 1 --json
218
+ artdam projects --json
219
+ artdam search "安妮" --json
192
220
  artdam get 123 --json
193
- artdam tags --project 1 --json
194
- artdam folders --project 1 --json
221
+ artdam tags --json
222
+ artdam folders --json
195
223
  ```
196
224
 
197
225
  ### 典型 Agent 工作流
198
226
 
199
227
  ```bash
200
- # 1. 登录(向用户获取用户名密码后执行)
228
+ # 1. 登录
201
229
  artdam login --username <用户名> --password <密码>
202
230
 
203
- # 2. 搜索 → 确认 → 下载
204
- artdam search "头盔" --project 1 --json
231
+ # 2. 查询项目列表,选择目标项目并设为默认
232
+ artdam projects --json
233
+ artdam project use 1
234
+
235
+ # 3. 搜索 → 确认 → 下载
236
+ artdam search "头盔" --json
205
237
  artdam get 50707 --json
206
238
  artdam download 50707 --out ./assets
207
239
 
208
- # 3. 搜索 → 批量打标签
209
- artdam search "安妮" --project 1 --json
240
+ # 4. 搜索 → 批量打标签
241
+ artdam search "安妮" --json
210
242
  artdam tag add 50707 5
211
243
  artdam tag add 50708 5
212
244
 
213
- # 4. 上传并更新描述
214
- artdam upload ./new_asset.jpg --project 1 --folder 10
245
+ # 5. 上传并更新描述
246
+ artdam upload ./new_asset.jpg --folder 10
215
247
  artdam update <asset_id> --description "AI 生成的场景描述"
216
248
  ```
217
249
 
218
250
  ## 注意事项
219
251
 
220
- - `--project` 参数为**数字 ID**,不是项目名称
252
+ - 首次使用先运行 `artdam projects` 获取项目 ID,再 `artdam project use <id>` 设置默认项目
253
+ - 设置默认项目后,`search` / `tags` / `folders` / `upload` 等命令无需再传 `-p`
254
+ - `-p` 仍可临时覆盖默认项目
221
255
  - `--json` 返回原始 JSON,适合程序解析
222
256
  - token 保存在 `~/.artdam/config.json`,登录一次长期有效
223
257
  - `artdam delete` 是软删除,可用 `artdam restore` 恢复
@@ -230,6 +264,7 @@ artdam update <asset_id> --description "AI 生成的场景描述"
230
264
  ```json
231
265
  {
232
266
  "base_url": "https://artdam.dsworks.cn",
233
- "token": "eyJ..."
267
+ "token": "eyJ...",
268
+ "default_project": 1
234
269
  }
235
270
  ```
@@ -20,6 +20,7 @@ artdam_cli/commands/folders.py
20
20
  artdam_cli/commands/get.py
21
21
  artdam_cli/commands/login.py
22
22
  artdam_cli/commands/project.py
23
+ artdam_cli/commands/projects.py
23
24
  artdam_cli/commands/rate.py
24
25
  artdam_cli/commands/restore.py
25
26
  artdam_cli/commands/search.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "artdam-cli"
7
- version = "0.2.0"
7
+ version = "0.2.1"
8
8
  requires-python = ">=3.10"
9
9
  description = "ArtDAM 数字资产管理平台命令行工具"
10
10
  readme = "README.md"
@@ -1 +0,0 @@
1
- __version__ = "0.2.0"
File without changes