artdam-cli 0.2.1__tar.gz → 0.2.2__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.
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/PKG-INFO +32 -67
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/README.md +31 -66
- artdam_cli-0.2.2/artdam_cli/__init__.py +1 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/artdam_cli/commands/folder_cmd.py +3 -4
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/artdam_cli/commands/folders.py +3 -4
- artdam_cli-0.2.2/artdam_cli/commands/login.py +112 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/artdam_cli/commands/search.py +3 -4
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/artdam_cli/commands/tag_cmd.py +3 -4
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/artdam_cli/commands/tags.py +3 -4
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/artdam_cli/commands/upload.py +3 -4
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/artdam_cli/config.py +0 -9
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/artdam_cli/main.py +0 -4
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/artdam_cli.egg-info/PKG-INFO +32 -67
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/artdam_cli.egg-info/SOURCES.txt +0 -2
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/pyproject.toml +1 -1
- artdam_cli-0.2.1/artdam_cli/__init__.py +0 -1
- artdam_cli-0.2.1/artdam_cli/commands/login.py +0 -31
- artdam_cli-0.2.1/artdam_cli/commands/project.py +0 -28
- artdam_cli-0.2.1/artdam_cli/commands/projects.py +0 -41
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/artdam_cli/client.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/artdam_cli/commands/__init__.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/artdam_cli/commands/comment.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/artdam_cli/commands/delete_cmd.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/artdam_cli/commands/download.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/artdam_cli/commands/favorite.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/artdam_cli/commands/get.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/artdam_cli/commands/rate.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/artdam_cli/commands/restore.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/artdam_cli/commands/update.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/artdam_cli.egg-info/dependency_links.txt +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/artdam_cli.egg-info/entry_points.txt +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/artdam_cli.egg-info/requires.txt +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/artdam_cli.egg-info/top_level.txt +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.2}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: artdam-cli
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: ArtDAM 数字资产管理平台命令行工具
|
|
5
5
|
Requires-Python: >=3.10
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -28,14 +28,8 @@ 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
|
-
|
|
37
31
|
# 搜索资产
|
|
38
|
-
artdam search "关键词"
|
|
32
|
+
artdam search "关键词" --project 1
|
|
39
33
|
|
|
40
34
|
# 查看资产详情
|
|
41
35
|
artdam get 123
|
|
@@ -48,24 +42,6 @@ artdam download 123 --out ./downloads
|
|
|
48
42
|
|
|
49
43
|
### 查询命令(viewer 及以上)
|
|
50
44
|
|
|
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
|
-
|
|
69
45
|
#### `artdam login`
|
|
70
46
|
|
|
71
47
|
登录 ArtDAM,保存 token 到本地 `~/.artdam/config.json`。
|
|
@@ -79,18 +55,17 @@ artdam login --username <用户名> --password <密码>
|
|
|
79
55
|
搜索资产,返回匹配列表。
|
|
80
56
|
|
|
81
57
|
```bash
|
|
82
|
-
artdam search "头盔"
|
|
83
|
-
artdam search "头盔" --project 1
|
|
84
|
-
artdam search "头盔" --
|
|
85
|
-
artdam search "头盔" --
|
|
86
|
-
artdam search "头盔" --
|
|
87
|
-
artdam search "头盔" --json # 输出原始 JSON(AI Agent 用)
|
|
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 用)
|
|
88
63
|
```
|
|
89
64
|
|
|
90
65
|
| 参数 | 说明 |
|
|
91
66
|
|---|---|
|
|
92
67
|
| `KEYWORD` | 搜索关键词 |
|
|
93
|
-
| `-p, --project` | 项目 ID
|
|
68
|
+
| `-p, --project` | 项目 ID(必填) |
|
|
94
69
|
| `-n, --limit` | 返回数量上限(默认 20) |
|
|
95
70
|
| `--type` | 文件类型,如 `image/png` |
|
|
96
71
|
| `--folder` | 限定文件夹 ID |
|
|
@@ -119,9 +94,9 @@ artdam download 123 --out ./downloads
|
|
|
119
94
|
列出项目标签。
|
|
120
95
|
|
|
121
96
|
```bash
|
|
122
|
-
artdam tags
|
|
123
|
-
artdam tags --search "角色"
|
|
124
|
-
artdam tags --json
|
|
97
|
+
artdam tags --project 1
|
|
98
|
+
artdam tags --project 1 --search "角色"
|
|
99
|
+
artdam tags --project 1 --json
|
|
125
100
|
```
|
|
126
101
|
|
|
127
102
|
#### `artdam folders`
|
|
@@ -129,8 +104,8 @@ artdam tags --json
|
|
|
129
104
|
查看文件夹结构。
|
|
130
105
|
|
|
131
106
|
```bash
|
|
132
|
-
artdam folders
|
|
133
|
-
artdam folders --json
|
|
107
|
+
artdam folders --project 1
|
|
108
|
+
artdam folders --project 1 --json
|
|
134
109
|
```
|
|
135
110
|
|
|
136
111
|
### 资产管理(member 及以上)
|
|
@@ -140,9 +115,8 @@ artdam folders --json
|
|
|
140
115
|
上传文件到指定项目和文件夹。
|
|
141
116
|
|
|
142
117
|
```bash
|
|
143
|
-
artdam upload ./image.jpg
|
|
144
|
-
artdam upload ./image.jpg --folder 10
|
|
145
|
-
artdam upload ./image.jpg --project 1 # 临时指定项目
|
|
118
|
+
artdam upload ./image.jpg --project 1
|
|
119
|
+
artdam upload ./image.jpg --project 1 --folder 10
|
|
146
120
|
```
|
|
147
121
|
|
|
148
122
|
#### `artdam update`
|
|
@@ -180,17 +154,16 @@ artdam tag add 123 5
|
|
|
180
154
|
# 从资产移除标签
|
|
181
155
|
artdam tag remove 123 5
|
|
182
156
|
|
|
183
|
-
#
|
|
184
|
-
artdam tag create "标签名"
|
|
157
|
+
# 创建新标签
|
|
185
158
|
artdam tag create "标签名" --project 1
|
|
186
159
|
```
|
|
187
160
|
|
|
188
161
|
### 文件夹管理(member 及以上)
|
|
189
162
|
|
|
190
163
|
```bash
|
|
191
|
-
#
|
|
192
|
-
artdam folder create "文件夹名"
|
|
193
|
-
artdam folder create "子文件夹" --parent 10
|
|
164
|
+
# 创建文件夹
|
|
165
|
+
artdam folder create "文件夹名" --project 1
|
|
166
|
+
artdam folder create "子文件夹" --project 1 --parent 10
|
|
194
167
|
|
|
195
168
|
# 删除文件夹
|
|
196
169
|
artdam folder delete 10
|
|
@@ -215,43 +188,36 @@ artdam favorite 123 --remove
|
|
|
215
188
|
所有查询命令支持 `--json` 输出原始 JSON,适合 Agent 解析:
|
|
216
189
|
|
|
217
190
|
```bash
|
|
218
|
-
artdam
|
|
219
|
-
artdam search "安妮" --json
|
|
191
|
+
artdam search "安妮" --project 1 --json
|
|
220
192
|
artdam get 123 --json
|
|
221
|
-
artdam tags --json
|
|
222
|
-
artdam folders --json
|
|
193
|
+
artdam tags --project 1 --json
|
|
194
|
+
artdam folders --project 1 --json
|
|
223
195
|
```
|
|
224
196
|
|
|
225
197
|
### 典型 Agent 工作流
|
|
226
198
|
|
|
227
199
|
```bash
|
|
228
|
-
# 1.
|
|
200
|
+
# 1. 登录(向用户获取用户名密码后执行)
|
|
229
201
|
artdam login --username <用户名> --password <密码>
|
|
230
202
|
|
|
231
|
-
# 2.
|
|
232
|
-
artdam
|
|
233
|
-
artdam project use 1
|
|
234
|
-
|
|
235
|
-
# 3. 搜索 → 确认 → 下载
|
|
236
|
-
artdam search "头盔" --json
|
|
203
|
+
# 2. 搜索 → 确认 → 下载
|
|
204
|
+
artdam search "头盔" --project 1 --json
|
|
237
205
|
artdam get 50707 --json
|
|
238
206
|
artdam download 50707 --out ./assets
|
|
239
207
|
|
|
240
|
-
#
|
|
241
|
-
artdam search "安妮" --json
|
|
208
|
+
# 3. 搜索 → 批量打标签
|
|
209
|
+
artdam search "安妮" --project 1 --json
|
|
242
210
|
artdam tag add 50707 5
|
|
243
211
|
artdam tag add 50708 5
|
|
244
212
|
|
|
245
|
-
#
|
|
246
|
-
artdam upload ./new_asset.jpg --folder 10
|
|
213
|
+
# 4. 上传并更新描述
|
|
214
|
+
artdam upload ./new_asset.jpg --project 1 --folder 10
|
|
247
215
|
artdam update <asset_id> --description "AI 生成的场景描述"
|
|
248
216
|
```
|
|
249
217
|
|
|
250
218
|
## 注意事项
|
|
251
219
|
|
|
252
|
-
-
|
|
253
|
-
- 设置默认项目后,`search` / `tags` / `folders` / `upload` 等命令无需再传 `-p`
|
|
254
|
-
- `-p` 仍可临时覆盖默认项目
|
|
220
|
+
- `--project` 参数为**数字 ID**,不是项目名称
|
|
255
221
|
- `--json` 返回原始 JSON,适合程序解析
|
|
256
222
|
- token 保存在 `~/.artdam/config.json`,登录一次长期有效
|
|
257
223
|
- `artdam delete` 是软删除,可用 `artdam restore` 恢复
|
|
@@ -263,8 +229,7 @@ artdam update <asset_id> --description "AI 生成的场景描述"
|
|
|
263
229
|
|
|
264
230
|
```json
|
|
265
231
|
{
|
|
266
|
-
"base_url": "https://artdam.
|
|
267
|
-
"token": "eyJ..."
|
|
268
|
-
"default_project": 1
|
|
232
|
+
"base_url": "https://artdam.xindong.com",
|
|
233
|
+
"token": "eyJ..."
|
|
269
234
|
}
|
|
270
235
|
```
|
|
@@ -18,14 +18,8 @@ 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
|
-
|
|
27
21
|
# 搜索资产
|
|
28
|
-
artdam search "关键词"
|
|
22
|
+
artdam search "关键词" --project 1
|
|
29
23
|
|
|
30
24
|
# 查看资产详情
|
|
31
25
|
artdam get 123
|
|
@@ -38,24 +32,6 @@ artdam download 123 --out ./downloads
|
|
|
38
32
|
|
|
39
33
|
### 查询命令(viewer 及以上)
|
|
40
34
|
|
|
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
|
-
|
|
59
35
|
#### `artdam login`
|
|
60
36
|
|
|
61
37
|
登录 ArtDAM,保存 token 到本地 `~/.artdam/config.json`。
|
|
@@ -69,18 +45,17 @@ artdam login --username <用户名> --password <密码>
|
|
|
69
45
|
搜索资产,返回匹配列表。
|
|
70
46
|
|
|
71
47
|
```bash
|
|
72
|
-
artdam search "头盔"
|
|
73
|
-
artdam search "头盔" --project 1
|
|
74
|
-
artdam search "头盔" --
|
|
75
|
-
artdam search "头盔" --
|
|
76
|
-
artdam search "头盔" --
|
|
77
|
-
artdam search "头盔" --json # 输出原始 JSON(AI Agent 用)
|
|
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 用)
|
|
78
53
|
```
|
|
79
54
|
|
|
80
55
|
| 参数 | 说明 |
|
|
81
56
|
|---|---|
|
|
82
57
|
| `KEYWORD` | 搜索关键词 |
|
|
83
|
-
| `-p, --project` | 项目 ID
|
|
58
|
+
| `-p, --project` | 项目 ID(必填) |
|
|
84
59
|
| `-n, --limit` | 返回数量上限(默认 20) |
|
|
85
60
|
| `--type` | 文件类型,如 `image/png` |
|
|
86
61
|
| `--folder` | 限定文件夹 ID |
|
|
@@ -109,9 +84,9 @@ artdam download 123 --out ./downloads
|
|
|
109
84
|
列出项目标签。
|
|
110
85
|
|
|
111
86
|
```bash
|
|
112
|
-
artdam tags
|
|
113
|
-
artdam tags --search "角色"
|
|
114
|
-
artdam tags --json
|
|
87
|
+
artdam tags --project 1
|
|
88
|
+
artdam tags --project 1 --search "角色"
|
|
89
|
+
artdam tags --project 1 --json
|
|
115
90
|
```
|
|
116
91
|
|
|
117
92
|
#### `artdam folders`
|
|
@@ -119,8 +94,8 @@ artdam tags --json
|
|
|
119
94
|
查看文件夹结构。
|
|
120
95
|
|
|
121
96
|
```bash
|
|
122
|
-
artdam folders
|
|
123
|
-
artdam folders --json
|
|
97
|
+
artdam folders --project 1
|
|
98
|
+
artdam folders --project 1 --json
|
|
124
99
|
```
|
|
125
100
|
|
|
126
101
|
### 资产管理(member 及以上)
|
|
@@ -130,9 +105,8 @@ artdam folders --json
|
|
|
130
105
|
上传文件到指定项目和文件夹。
|
|
131
106
|
|
|
132
107
|
```bash
|
|
133
|
-
artdam upload ./image.jpg
|
|
134
|
-
artdam upload ./image.jpg --folder 10
|
|
135
|
-
artdam upload ./image.jpg --project 1 # 临时指定项目
|
|
108
|
+
artdam upload ./image.jpg --project 1
|
|
109
|
+
artdam upload ./image.jpg --project 1 --folder 10
|
|
136
110
|
```
|
|
137
111
|
|
|
138
112
|
#### `artdam update`
|
|
@@ -170,17 +144,16 @@ artdam tag add 123 5
|
|
|
170
144
|
# 从资产移除标签
|
|
171
145
|
artdam tag remove 123 5
|
|
172
146
|
|
|
173
|
-
#
|
|
174
|
-
artdam tag create "标签名"
|
|
147
|
+
# 创建新标签
|
|
175
148
|
artdam tag create "标签名" --project 1
|
|
176
149
|
```
|
|
177
150
|
|
|
178
151
|
### 文件夹管理(member 及以上)
|
|
179
152
|
|
|
180
153
|
```bash
|
|
181
|
-
#
|
|
182
|
-
artdam folder create "文件夹名"
|
|
183
|
-
artdam folder create "子文件夹" --parent 10
|
|
154
|
+
# 创建文件夹
|
|
155
|
+
artdam folder create "文件夹名" --project 1
|
|
156
|
+
artdam folder create "子文件夹" --project 1 --parent 10
|
|
184
157
|
|
|
185
158
|
# 删除文件夹
|
|
186
159
|
artdam folder delete 10
|
|
@@ -205,43 +178,36 @@ artdam favorite 123 --remove
|
|
|
205
178
|
所有查询命令支持 `--json` 输出原始 JSON,适合 Agent 解析:
|
|
206
179
|
|
|
207
180
|
```bash
|
|
208
|
-
artdam
|
|
209
|
-
artdam search "安妮" --json
|
|
181
|
+
artdam search "安妮" --project 1 --json
|
|
210
182
|
artdam get 123 --json
|
|
211
|
-
artdam tags --json
|
|
212
|
-
artdam folders --json
|
|
183
|
+
artdam tags --project 1 --json
|
|
184
|
+
artdam folders --project 1 --json
|
|
213
185
|
```
|
|
214
186
|
|
|
215
187
|
### 典型 Agent 工作流
|
|
216
188
|
|
|
217
189
|
```bash
|
|
218
|
-
# 1.
|
|
190
|
+
# 1. 登录(向用户获取用户名密码后执行)
|
|
219
191
|
artdam login --username <用户名> --password <密码>
|
|
220
192
|
|
|
221
|
-
# 2.
|
|
222
|
-
artdam
|
|
223
|
-
artdam project use 1
|
|
224
|
-
|
|
225
|
-
# 3. 搜索 → 确认 → 下载
|
|
226
|
-
artdam search "头盔" --json
|
|
193
|
+
# 2. 搜索 → 确认 → 下载
|
|
194
|
+
artdam search "头盔" --project 1 --json
|
|
227
195
|
artdam get 50707 --json
|
|
228
196
|
artdam download 50707 --out ./assets
|
|
229
197
|
|
|
230
|
-
#
|
|
231
|
-
artdam search "安妮" --json
|
|
198
|
+
# 3. 搜索 → 批量打标签
|
|
199
|
+
artdam search "安妮" --project 1 --json
|
|
232
200
|
artdam tag add 50707 5
|
|
233
201
|
artdam tag add 50708 5
|
|
234
202
|
|
|
235
|
-
#
|
|
236
|
-
artdam upload ./new_asset.jpg --folder 10
|
|
203
|
+
# 4. 上传并更新描述
|
|
204
|
+
artdam upload ./new_asset.jpg --project 1 --folder 10
|
|
237
205
|
artdam update <asset_id> --description "AI 生成的场景描述"
|
|
238
206
|
```
|
|
239
207
|
|
|
240
208
|
## 注意事项
|
|
241
209
|
|
|
242
|
-
-
|
|
243
|
-
- 设置默认项目后,`search` / `tags` / `folders` / `upload` 等命令无需再传 `-p`
|
|
244
|
-
- `-p` 仍可临时覆盖默认项目
|
|
210
|
+
- `--project` 参数为**数字 ID**,不是项目名称
|
|
245
211
|
- `--json` 返回原始 JSON,适合程序解析
|
|
246
212
|
- token 保存在 `~/.artdam/config.json`,登录一次长期有效
|
|
247
213
|
- `artdam delete` 是软删除,可用 `artdam restore` 恢复
|
|
@@ -253,8 +219,7 @@ artdam update <asset_id> --description "AI 生成的场景描述"
|
|
|
253
219
|
|
|
254
220
|
```json
|
|
255
221
|
{
|
|
256
|
-
"base_url": "https://artdam.
|
|
257
|
-
"token": "eyJ..."
|
|
258
|
-
"default_project": 1
|
|
222
|
+
"base_url": "https://artdam.xindong.com",
|
|
223
|
+
"token": "eyJ..."
|
|
259
224
|
}
|
|
260
225
|
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import click
|
|
2
2
|
|
|
3
|
-
from artdam_cli import client
|
|
3
|
+
from artdam_cli import client
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
@click.group(name="folder")
|
|
@@ -10,11 +10,10 @@ def folder_group() -> None:
|
|
|
10
10
|
|
|
11
11
|
@folder_group.command(name="create")
|
|
12
12
|
@click.argument("name")
|
|
13
|
-
@click.option("--project", "-p", type=int,
|
|
13
|
+
@click.option("--project", "-p", type=int, required=True, help="项目 ID")
|
|
14
14
|
@click.option("--parent", type=int, default=None, help="父文件夹 ID(不填则创建在根目录)")
|
|
15
|
-
def folder_create(name: str, project: int
|
|
15
|
+
def folder_create(name: str, project: int, parent: int | None) -> None:
|
|
16
16
|
"""创建文件夹。"""
|
|
17
|
-
project = config.require_project(project)
|
|
18
17
|
body: dict = {"name": name, "project_id": project}
|
|
19
18
|
if parent is not None:
|
|
20
19
|
body["parent_id"] = parent
|
|
@@ -4,7 +4,7 @@ import click
|
|
|
4
4
|
from rich.console import Console
|
|
5
5
|
from rich.tree import Tree
|
|
6
6
|
|
|
7
|
-
from artdam_cli import client
|
|
7
|
+
from artdam_cli import client
|
|
8
8
|
|
|
9
9
|
console = Console()
|
|
10
10
|
|
|
@@ -17,11 +17,10 @@ def _build_tree(node: Tree, items: list[dict], parent_id: int | None) -> None:
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
@click.command()
|
|
20
|
-
@click.option("--project", "-p",
|
|
20
|
+
@click.option("--project", "-p", required=True, type=int, help="项目 ID")
|
|
21
21
|
@click.option("--json", "as_json", is_flag=True, help="输出原始 JSON")
|
|
22
|
-
def folders(project: int
|
|
22
|
+
def folders(project: int, as_json: bool) -> None:
|
|
23
23
|
"""查看文件夹结构。"""
|
|
24
|
-
project = config.require_project(project)
|
|
25
24
|
data = client.get("/api/collections/", params={"project_id": project})
|
|
26
25
|
items = data if isinstance(data, list) else data.get("items", [])
|
|
27
26
|
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import threading
|
|
2
|
+
import webbrowser
|
|
3
|
+
from http.server import BaseHTTPRequestHandler, HTTPServer
|
|
4
|
+
from urllib.parse import parse_qs, urlparse
|
|
5
|
+
|
|
6
|
+
import click
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from artdam_cli import config
|
|
10
|
+
|
|
11
|
+
_SUCCESS_HTML = """<!DOCTYPE html>
|
|
12
|
+
<html><head><meta charset="utf-8"><title>ArtDAM CLI</title>
|
|
13
|
+
<style>body{font-family:sans-serif;text-align:center;padding:80px;background:#0b1117;color:#edf2f7}
|
|
14
|
+
h2{color:#7eb893}p{color:#b7c2ce}</style></head>
|
|
15
|
+
<body><h2>✅ SSO 登录成功</h2>
|
|
16
|
+
<p>可以关闭此页面,返回终端继续操作。</p>
|
|
17
|
+
</body></html>""".encode()
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _sso_login(url: str) -> None:
|
|
21
|
+
"""Browser Callback Flow:启动本地 HTTP server,打开浏览器走完整 CAS SSO 流程。"""
|
|
22
|
+
token_holder: dict = {"value": None}
|
|
23
|
+
done = threading.Event()
|
|
24
|
+
|
|
25
|
+
class _Handler(BaseHTTPRequestHandler):
|
|
26
|
+
def do_GET(self):
|
|
27
|
+
params = parse_qs(urlparse(self.path).query)
|
|
28
|
+
token = params.get("token", [None])[0]
|
|
29
|
+
if token:
|
|
30
|
+
token_holder["value"] = token
|
|
31
|
+
self.send_response(200)
|
|
32
|
+
self.send_header("Content-Type", "text/html; charset=utf-8")
|
|
33
|
+
self.end_headers()
|
|
34
|
+
self.wfile.write(_SUCCESS_HTML)
|
|
35
|
+
done.set()
|
|
36
|
+
else:
|
|
37
|
+
self.send_response(400)
|
|
38
|
+
self.end_headers()
|
|
39
|
+
|
|
40
|
+
def log_message(self, *_): # 抑制默认 server 日志
|
|
41
|
+
pass
|
|
42
|
+
|
|
43
|
+
# 绑定 port=0 让 OS 分配可用端口,避免 find-then-bind 竞争
|
|
44
|
+
server = HTTPServer(("127.0.0.1", 0), _Handler)
|
|
45
|
+
port = server.server_address[1]
|
|
46
|
+
|
|
47
|
+
t = threading.Thread(target=server.serve_forever, daemon=True)
|
|
48
|
+
t.start()
|
|
49
|
+
|
|
50
|
+
login_url = f"{url}/api/auth/sso/login?cli_port={port}"
|
|
51
|
+
click.echo("正在打开浏览器进行 SSO 登录...")
|
|
52
|
+
if not webbrowser.open(login_url):
|
|
53
|
+
click.echo(f"无法自动打开浏览器,请手动访问:\n {login_url}")
|
|
54
|
+
|
|
55
|
+
click.echo("等待 SSO 授权(120 秒超时)...")
|
|
56
|
+
if not done.wait(timeout=120):
|
|
57
|
+
server.shutdown()
|
|
58
|
+
raise SystemExit("登录超时(120 秒),请重试")
|
|
59
|
+
|
|
60
|
+
server.shutdown()
|
|
61
|
+
config.save({"base_url": url, "token": token_holder["value"]})
|
|
62
|
+
click.echo("✓ SSO 登录成功,配置已保存到 ~/.artdam/config.json")
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _password_login(url: str, username: str | None, passwd: str | None) -> None:
|
|
66
|
+
"""账号密码登录(仅 admin / 服务账号使用)。"""
|
|
67
|
+
if not username:
|
|
68
|
+
username = click.prompt("用户名")
|
|
69
|
+
if not passwd:
|
|
70
|
+
passwd = click.prompt("密码", hide_input=True)
|
|
71
|
+
try:
|
|
72
|
+
r = httpx.post(
|
|
73
|
+
f"{url}/api/auth/login",
|
|
74
|
+
json={"username": username, "password": passwd},
|
|
75
|
+
timeout=10,
|
|
76
|
+
)
|
|
77
|
+
except httpx.ConnectError:
|
|
78
|
+
raise SystemExit(f"无法连接到 {url},请检查地址")
|
|
79
|
+
if r.status_code != 200:
|
|
80
|
+
raise SystemExit(f"登录失败: {r.json().get('detail', r.text)}")
|
|
81
|
+
token = r.json().get("access_token")
|
|
82
|
+
if not token:
|
|
83
|
+
raise SystemExit("登录响应中未找到 token")
|
|
84
|
+
config.save({"base_url": url, "token": token})
|
|
85
|
+
click.echo("✓ 登录成功,配置已保存到 ~/.artdam/config.json")
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
@click.command()
|
|
89
|
+
@click.option(
|
|
90
|
+
"--url",
|
|
91
|
+
default="https://artdam.xindong.com",
|
|
92
|
+
help="服务器地址,默认: https://artdam.xindong.com",
|
|
93
|
+
)
|
|
94
|
+
@click.option(
|
|
95
|
+
"--password",
|
|
96
|
+
"use_password",
|
|
97
|
+
is_flag=True,
|
|
98
|
+
help="使用账号密码登录(仅 admin/服务账号,默认走 SSO)",
|
|
99
|
+
)
|
|
100
|
+
@click.option("--username", default=None, help="用户名(仅 --password 模式)")
|
|
101
|
+
@click.option(
|
|
102
|
+
"--passwd", default=None, hide_input=True, help="密码(仅 --password 模式)"
|
|
103
|
+
)
|
|
104
|
+
def login(
|
|
105
|
+
url: str, use_password: bool, username: str | None, passwd: str | None
|
|
106
|
+
) -> None:
|
|
107
|
+
"""登录 ArtDAM。默认走 SSO 浏览器授权,加 --password 使用账号密码(仅管理员)。"""
|
|
108
|
+
url = url.rstrip("/")
|
|
109
|
+
if use_password:
|
|
110
|
+
_password_login(url, username, passwd)
|
|
111
|
+
else:
|
|
112
|
+
_sso_login(url)
|
|
@@ -4,21 +4,20 @@ import click
|
|
|
4
4
|
from rich.console import Console
|
|
5
5
|
from rich.table import Table
|
|
6
6
|
|
|
7
|
-
from artdam_cli import client
|
|
7
|
+
from artdam_cli import client
|
|
8
8
|
|
|
9
9
|
console = Console()
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
@click.command()
|
|
13
13
|
@click.argument("keyword")
|
|
14
|
-
@click.option("--project", "-p",
|
|
14
|
+
@click.option("--project", "-p", required=True, type=int, help="项目 ID")
|
|
15
15
|
@click.option("--limit", "-n", default=20, show_default=True, help="返回数量上限")
|
|
16
16
|
@click.option("--type", "mime", default=None, help="文件类型,例: image/png")
|
|
17
17
|
@click.option("--folder", default=None, type=int, help="限定文件夹 ID")
|
|
18
18
|
@click.option("--json", "as_json", is_flag=True, help="输出原始 JSON(AI Agent 用)")
|
|
19
|
-
def search(keyword: str, project: int
|
|
19
|
+
def search(keyword: str, project: int, limit: int, mime: str | None, folder: int | None, as_json: bool) -> None:
|
|
20
20
|
"""搜索资产。"""
|
|
21
|
-
project = config.require_project(project)
|
|
22
21
|
params: dict = {
|
|
23
22
|
"project_id": project,
|
|
24
23
|
"q": keyword,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import click
|
|
2
2
|
|
|
3
|
-
from artdam_cli import client
|
|
3
|
+
from artdam_cli import client
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
@click.group(name="tag")
|
|
@@ -28,9 +28,8 @@ def tag_remove(asset_id: int, tag_id: int) -> None:
|
|
|
28
28
|
|
|
29
29
|
@tag_group.command(name="create")
|
|
30
30
|
@click.argument("name")
|
|
31
|
-
@click.option("--project", "-p", type=int,
|
|
32
|
-
def tag_create(name: str, project: int
|
|
31
|
+
@click.option("--project", "-p", type=int, required=True, help="项目 ID")
|
|
32
|
+
def tag_create(name: str, project: int) -> None:
|
|
33
33
|
"""创建新标签。"""
|
|
34
|
-
project = config.require_project(project)
|
|
35
34
|
data = client.post("/api/tags/", {"name": name, "project_id": project})
|
|
36
35
|
click.echo(f"✓ 标签已创建 id={data.get('id')} name={data.get('name')}")
|
|
@@ -4,18 +4,17 @@ import click
|
|
|
4
4
|
from rich.console import Console
|
|
5
5
|
from rich.table import Table
|
|
6
6
|
|
|
7
|
-
from artdam_cli import client
|
|
7
|
+
from artdam_cli import client
|
|
8
8
|
|
|
9
9
|
console = Console()
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
@click.command()
|
|
13
|
-
@click.option("--project", "-p",
|
|
13
|
+
@click.option("--project", "-p", required=True, type=int, help="项目 ID")
|
|
14
14
|
@click.option("--search", "-s", default=None, help="按名称过滤")
|
|
15
15
|
@click.option("--json", "as_json", is_flag=True, help="输出原始 JSON")
|
|
16
|
-
def tags(project: int
|
|
16
|
+
def tags(project: int, search: str | None, as_json: bool) -> None:
|
|
17
17
|
"""列出项目标签。"""
|
|
18
|
-
project = config.require_project(project)
|
|
19
18
|
params: dict = {"project_id": project}
|
|
20
19
|
if search:
|
|
21
20
|
data = client.get("/api/tags/search", params={"project_id": project, "q": search})
|
|
@@ -2,16 +2,15 @@ import os
|
|
|
2
2
|
|
|
3
3
|
import click
|
|
4
4
|
|
|
5
|
-
from artdam_cli import client
|
|
5
|
+
from artdam_cli import client
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
@click.command()
|
|
9
9
|
@click.argument("file_path", type=click.Path(exists=True))
|
|
10
|
-
@click.option("--project", "-p", type=int,
|
|
10
|
+
@click.option("--project", "-p", type=int, required=True, help="项目 ID")
|
|
11
11
|
@click.option("--folder", "-f", type=int, default=None, help="目标文件夹 ID")
|
|
12
|
-
def upload(file_path: str, project: int
|
|
12
|
+
def upload(file_path: str, project: int, folder: int | None) -> None:
|
|
13
13
|
"""上传文件到 ArtDAM。"""
|
|
14
|
-
project = config.require_project(project)
|
|
15
14
|
params: dict = {"project_id": project}
|
|
16
15
|
if folder is not None:
|
|
17
16
|
params["folder_id"] = folder
|
|
@@ -28,12 +28,3 @@ def require(key: str) -> str:
|
|
|
28
28
|
if not value:
|
|
29
29
|
raise SystemExit(f"未配置 {key},请先运行: artdam login")
|
|
30
30
|
return value
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def require_project(provided: int | None) -> int:
|
|
34
|
-
if provided is not None:
|
|
35
|
-
return provided
|
|
36
|
-
value = get("default_project")
|
|
37
|
-
if value is None:
|
|
38
|
-
raise SystemExit("未指定项目 ID,请用 -p <id> 或先运行: artdam project use <id>")
|
|
39
|
-
return int(value)
|
|
@@ -15,8 +15,6 @@ from artdam_cli.commands.folder_cmd import folder_group
|
|
|
15
15
|
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
|
-
from artdam_cli.commands.project import project_group
|
|
19
|
-
from artdam_cli.commands.projects import projects
|
|
20
18
|
|
|
21
19
|
|
|
22
20
|
@click.group()
|
|
@@ -40,5 +38,3 @@ cli.add_command(folder_group)
|
|
|
40
38
|
cli.add_command(comment)
|
|
41
39
|
cli.add_command(rate)
|
|
42
40
|
cli.add_command(favorite)
|
|
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.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: ArtDAM 数字资产管理平台命令行工具
|
|
5
5
|
Requires-Python: >=3.10
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -28,14 +28,8 @@ 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
|
-
|
|
37
31
|
# 搜索资产
|
|
38
|
-
artdam search "关键词"
|
|
32
|
+
artdam search "关键词" --project 1
|
|
39
33
|
|
|
40
34
|
# 查看资产详情
|
|
41
35
|
artdam get 123
|
|
@@ -48,24 +42,6 @@ artdam download 123 --out ./downloads
|
|
|
48
42
|
|
|
49
43
|
### 查询命令(viewer 及以上)
|
|
50
44
|
|
|
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
|
-
|
|
69
45
|
#### `artdam login`
|
|
70
46
|
|
|
71
47
|
登录 ArtDAM,保存 token 到本地 `~/.artdam/config.json`。
|
|
@@ -79,18 +55,17 @@ artdam login --username <用户名> --password <密码>
|
|
|
79
55
|
搜索资产,返回匹配列表。
|
|
80
56
|
|
|
81
57
|
```bash
|
|
82
|
-
artdam search "头盔"
|
|
83
|
-
artdam search "头盔" --project 1
|
|
84
|
-
artdam search "头盔" --
|
|
85
|
-
artdam search "头盔" --
|
|
86
|
-
artdam search "头盔" --
|
|
87
|
-
artdam search "头盔" --json # 输出原始 JSON(AI Agent 用)
|
|
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 用)
|
|
88
63
|
```
|
|
89
64
|
|
|
90
65
|
| 参数 | 说明 |
|
|
91
66
|
|---|---|
|
|
92
67
|
| `KEYWORD` | 搜索关键词 |
|
|
93
|
-
| `-p, --project` | 项目 ID
|
|
68
|
+
| `-p, --project` | 项目 ID(必填) |
|
|
94
69
|
| `-n, --limit` | 返回数量上限(默认 20) |
|
|
95
70
|
| `--type` | 文件类型,如 `image/png` |
|
|
96
71
|
| `--folder` | 限定文件夹 ID |
|
|
@@ -119,9 +94,9 @@ artdam download 123 --out ./downloads
|
|
|
119
94
|
列出项目标签。
|
|
120
95
|
|
|
121
96
|
```bash
|
|
122
|
-
artdam tags
|
|
123
|
-
artdam tags --search "角色"
|
|
124
|
-
artdam tags --json
|
|
97
|
+
artdam tags --project 1
|
|
98
|
+
artdam tags --project 1 --search "角色"
|
|
99
|
+
artdam tags --project 1 --json
|
|
125
100
|
```
|
|
126
101
|
|
|
127
102
|
#### `artdam folders`
|
|
@@ -129,8 +104,8 @@ artdam tags --json
|
|
|
129
104
|
查看文件夹结构。
|
|
130
105
|
|
|
131
106
|
```bash
|
|
132
|
-
artdam folders
|
|
133
|
-
artdam folders --json
|
|
107
|
+
artdam folders --project 1
|
|
108
|
+
artdam folders --project 1 --json
|
|
134
109
|
```
|
|
135
110
|
|
|
136
111
|
### 资产管理(member 及以上)
|
|
@@ -140,9 +115,8 @@ artdam folders --json
|
|
|
140
115
|
上传文件到指定项目和文件夹。
|
|
141
116
|
|
|
142
117
|
```bash
|
|
143
|
-
artdam upload ./image.jpg
|
|
144
|
-
artdam upload ./image.jpg --folder 10
|
|
145
|
-
artdam upload ./image.jpg --project 1 # 临时指定项目
|
|
118
|
+
artdam upload ./image.jpg --project 1
|
|
119
|
+
artdam upload ./image.jpg --project 1 --folder 10
|
|
146
120
|
```
|
|
147
121
|
|
|
148
122
|
#### `artdam update`
|
|
@@ -180,17 +154,16 @@ artdam tag add 123 5
|
|
|
180
154
|
# 从资产移除标签
|
|
181
155
|
artdam tag remove 123 5
|
|
182
156
|
|
|
183
|
-
#
|
|
184
|
-
artdam tag create "标签名"
|
|
157
|
+
# 创建新标签
|
|
185
158
|
artdam tag create "标签名" --project 1
|
|
186
159
|
```
|
|
187
160
|
|
|
188
161
|
### 文件夹管理(member 及以上)
|
|
189
162
|
|
|
190
163
|
```bash
|
|
191
|
-
#
|
|
192
|
-
artdam folder create "文件夹名"
|
|
193
|
-
artdam folder create "子文件夹" --parent 10
|
|
164
|
+
# 创建文件夹
|
|
165
|
+
artdam folder create "文件夹名" --project 1
|
|
166
|
+
artdam folder create "子文件夹" --project 1 --parent 10
|
|
194
167
|
|
|
195
168
|
# 删除文件夹
|
|
196
169
|
artdam folder delete 10
|
|
@@ -215,43 +188,36 @@ artdam favorite 123 --remove
|
|
|
215
188
|
所有查询命令支持 `--json` 输出原始 JSON,适合 Agent 解析:
|
|
216
189
|
|
|
217
190
|
```bash
|
|
218
|
-
artdam
|
|
219
|
-
artdam search "安妮" --json
|
|
191
|
+
artdam search "安妮" --project 1 --json
|
|
220
192
|
artdam get 123 --json
|
|
221
|
-
artdam tags --json
|
|
222
|
-
artdam folders --json
|
|
193
|
+
artdam tags --project 1 --json
|
|
194
|
+
artdam folders --project 1 --json
|
|
223
195
|
```
|
|
224
196
|
|
|
225
197
|
### 典型 Agent 工作流
|
|
226
198
|
|
|
227
199
|
```bash
|
|
228
|
-
# 1.
|
|
200
|
+
# 1. 登录(向用户获取用户名密码后执行)
|
|
229
201
|
artdam login --username <用户名> --password <密码>
|
|
230
202
|
|
|
231
|
-
# 2.
|
|
232
|
-
artdam
|
|
233
|
-
artdam project use 1
|
|
234
|
-
|
|
235
|
-
# 3. 搜索 → 确认 → 下载
|
|
236
|
-
artdam search "头盔" --json
|
|
203
|
+
# 2. 搜索 → 确认 → 下载
|
|
204
|
+
artdam search "头盔" --project 1 --json
|
|
237
205
|
artdam get 50707 --json
|
|
238
206
|
artdam download 50707 --out ./assets
|
|
239
207
|
|
|
240
|
-
#
|
|
241
|
-
artdam search "安妮" --json
|
|
208
|
+
# 3. 搜索 → 批量打标签
|
|
209
|
+
artdam search "安妮" --project 1 --json
|
|
242
210
|
artdam tag add 50707 5
|
|
243
211
|
artdam tag add 50708 5
|
|
244
212
|
|
|
245
|
-
#
|
|
246
|
-
artdam upload ./new_asset.jpg --folder 10
|
|
213
|
+
# 4. 上传并更新描述
|
|
214
|
+
artdam upload ./new_asset.jpg --project 1 --folder 10
|
|
247
215
|
artdam update <asset_id> --description "AI 生成的场景描述"
|
|
248
216
|
```
|
|
249
217
|
|
|
250
218
|
## 注意事项
|
|
251
219
|
|
|
252
|
-
-
|
|
253
|
-
- 设置默认项目后,`search` / `tags` / `folders` / `upload` 等命令无需再传 `-p`
|
|
254
|
-
- `-p` 仍可临时覆盖默认项目
|
|
220
|
+
- `--project` 参数为**数字 ID**,不是项目名称
|
|
255
221
|
- `--json` 返回原始 JSON,适合程序解析
|
|
256
222
|
- token 保存在 `~/.artdam/config.json`,登录一次长期有效
|
|
257
223
|
- `artdam delete` 是软删除,可用 `artdam restore` 恢复
|
|
@@ -263,8 +229,7 @@ artdam update <asset_id> --description "AI 生成的场景描述"
|
|
|
263
229
|
|
|
264
230
|
```json
|
|
265
231
|
{
|
|
266
|
-
"base_url": "https://artdam.
|
|
267
|
-
"token": "eyJ..."
|
|
268
|
-
"default_project": 1
|
|
232
|
+
"base_url": "https://artdam.xindong.com",
|
|
233
|
+
"token": "eyJ..."
|
|
269
234
|
}
|
|
270
235
|
```
|
|
@@ -19,8 +19,6 @@ artdam_cli/commands/folder_cmd.py
|
|
|
19
19
|
artdam_cli/commands/folders.py
|
|
20
20
|
artdam_cli/commands/get.py
|
|
21
21
|
artdam_cli/commands/login.py
|
|
22
|
-
artdam_cli/commands/project.py
|
|
23
|
-
artdam_cli/commands/projects.py
|
|
24
22
|
artdam_cli/commands/rate.py
|
|
25
23
|
artdam_cli/commands/restore.py
|
|
26
24
|
artdam_cli/commands/search.py
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.1"
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import click
|
|
2
|
-
import httpx
|
|
3
|
-
|
|
4
|
-
from artdam_cli import config
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@click.command()
|
|
8
|
-
@click.option("--url", default="https://artdam.dsworks.cn", help="服务器地址,默认: https://artdam.dsworks.cn")
|
|
9
|
-
@click.option("--username", prompt="用户名")
|
|
10
|
-
@click.option("--password", prompt="密码", hide_input=True)
|
|
11
|
-
def login(url: str, username: str, password: str) -> None:
|
|
12
|
-
"""登录 ArtDAM,保存 token 到本地。"""
|
|
13
|
-
url = url.rstrip("/")
|
|
14
|
-
try:
|
|
15
|
-
r = httpx.post(
|
|
16
|
-
f"{url}/api/auth/login",
|
|
17
|
-
json={"username": username, "password": password},
|
|
18
|
-
timeout=10,
|
|
19
|
-
)
|
|
20
|
-
except httpx.ConnectError:
|
|
21
|
-
raise SystemExit(f"无法连接到 {url},请检查地址")
|
|
22
|
-
|
|
23
|
-
if r.status_code != 200:
|
|
24
|
-
raise SystemExit(f"登录失败: {r.json().get('detail', r.text)}")
|
|
25
|
-
|
|
26
|
-
token = r.json().get("access_token")
|
|
27
|
-
if not token:
|
|
28
|
-
raise SystemExit("登录响应中未找到 token")
|
|
29
|
-
|
|
30
|
-
config.save({"base_url": url, "token": token})
|
|
31
|
-
click.echo(f"✓ 登录成功,配置已保存到 ~/.artdam/config.json")
|
|
@@ -1,28 +0,0 @@
|
|
|
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,41 +0,0 @@
|
|
|
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)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|