artdam-cli 0.2.1__tar.gz → 0.2.3__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.3}/PKG-INFO +32 -13
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/README.md +31 -12
- artdam_cli-0.2.3/artdam_cli/commands/login.py +112 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli/commands/projects.py +41 -41
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli/main.py +8 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli.egg-info/PKG-INFO +32 -13
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/pyproject.toml +1 -1
- artdam_cli-0.2.1/artdam_cli/commands/login.py +0 -31
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli/__init__.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli/client.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli/commands/__init__.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli/commands/comment.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli/commands/delete_cmd.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli/commands/download.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli/commands/favorite.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli/commands/folder_cmd.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli/commands/folders.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli/commands/get.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli/commands/project.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli/commands/rate.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli/commands/restore.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli/commands/search.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli/commands/tag_cmd.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli/commands/tags.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli/commands/update.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli/commands/upload.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli/config.py +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli.egg-info/SOURCES.txt +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli.egg-info/dependency_links.txt +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli.egg-info/entry_points.txt +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli.egg-info/requires.txt +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/artdam_cli.egg-info/top_level.txt +0 -0
- {artdam_cli-0.2.1 → artdam_cli-0.2.3}/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.3
|
|
4
4
|
Summary: ArtDAM 数字资产管理平台命令行工具
|
|
5
5
|
Requires-Python: >=3.10
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -25,8 +25,11 @@ pip install artdam-cli
|
|
|
25
25
|
## 快速开始
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
#
|
|
29
|
-
artdam login
|
|
28
|
+
# 登录(默认走 SSO,自动打开浏览器完成授权)
|
|
29
|
+
artdam login
|
|
30
|
+
|
|
31
|
+
# 用账号密码登录
|
|
32
|
+
artdam login --password --username <用户名>
|
|
30
33
|
|
|
31
34
|
# 查看可访问的项目列表(获取项目 ID)
|
|
32
35
|
artdam projects
|
|
@@ -70,21 +73,37 @@ artdam project show # 查看当前默认项目
|
|
|
70
73
|
|
|
71
74
|
登录 ArtDAM,保存 token 到本地 `~/.artdam/config.json`。
|
|
72
75
|
|
|
76
|
+
**默认走 SSO 浏览器授权**(推荐):
|
|
77
|
+
|
|
73
78
|
```bash
|
|
74
|
-
artdam login
|
|
79
|
+
artdam login
|
|
80
|
+
# 自动打开浏览器 → 完成公司 SSO 授权 → token 写入本地配置
|
|
75
81
|
```
|
|
76
82
|
|
|
83
|
+
**账号密码登录**(仅管理员 / 服务账号):
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
artdam login --password --username <用户名>
|
|
87
|
+
# 回车后提示输入密码(不回显)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
| 参数 | 说明 |
|
|
91
|
+
|---|---|
|
|
92
|
+
| `--url` | 服务器地址(默认已内置,无需填写) |
|
|
93
|
+
| `--password` | 切换为账号密码模式(不加此 flag 默认走 SSO) |
|
|
94
|
+
| `--username` | 用户名(仅 `--password` 模式) |
|
|
95
|
+
|
|
77
96
|
#### `artdam search`
|
|
78
97
|
|
|
79
98
|
搜索资产,返回匹配列表。
|
|
80
99
|
|
|
81
100
|
```bash
|
|
82
|
-
artdam search "
|
|
83
|
-
artdam search "
|
|
84
|
-
artdam search "
|
|
85
|
-
artdam search "
|
|
86
|
-
artdam search "
|
|
87
|
-
artdam search "
|
|
101
|
+
artdam search "场景" # 使用默认项目
|
|
102
|
+
artdam search "场景" --project 1 # 临时指定项目
|
|
103
|
+
artdam search "场景" --limit 50
|
|
104
|
+
artdam search "场景" --type image/png
|
|
105
|
+
artdam search "场景" --folder 10
|
|
106
|
+
artdam search "场景" --json # 输出原始 JSON(AI Agent 用)
|
|
88
107
|
```
|
|
89
108
|
|
|
90
109
|
| 参数 | 说明 |
|
|
@@ -225,8 +244,8 @@ artdam folders --json
|
|
|
225
244
|
### 典型 Agent 工作流
|
|
226
245
|
|
|
227
246
|
```bash
|
|
228
|
-
# 1.
|
|
229
|
-
artdam login
|
|
247
|
+
# 1. 登录(SSO 浏览器授权,完成后自动保存 token)
|
|
248
|
+
artdam login
|
|
230
249
|
|
|
231
250
|
# 2. 查询项目列表,选择目标项目并设为默认
|
|
232
251
|
artdam projects --json
|
|
@@ -263,7 +282,7 @@ artdam update <asset_id> --description "AI 生成的场景描述"
|
|
|
263
282
|
|
|
264
283
|
```json
|
|
265
284
|
{
|
|
266
|
-
"base_url": "https://artdam.
|
|
285
|
+
"base_url": "https://artdam.xindong.com",
|
|
267
286
|
"token": "eyJ...",
|
|
268
287
|
"default_project": 1
|
|
269
288
|
}
|
|
@@ -15,8 +15,11 @@ pip install artdam-cli
|
|
|
15
15
|
## 快速开始
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
#
|
|
19
|
-
artdam login
|
|
18
|
+
# 登录(默认走 SSO,自动打开浏览器完成授权)
|
|
19
|
+
artdam login
|
|
20
|
+
|
|
21
|
+
# 用账号密码登录
|
|
22
|
+
artdam login --password --username <用户名>
|
|
20
23
|
|
|
21
24
|
# 查看可访问的项目列表(获取项目 ID)
|
|
22
25
|
artdam projects
|
|
@@ -60,21 +63,37 @@ artdam project show # 查看当前默认项目
|
|
|
60
63
|
|
|
61
64
|
登录 ArtDAM,保存 token 到本地 `~/.artdam/config.json`。
|
|
62
65
|
|
|
66
|
+
**默认走 SSO 浏览器授权**(推荐):
|
|
67
|
+
|
|
63
68
|
```bash
|
|
64
|
-
artdam login
|
|
69
|
+
artdam login
|
|
70
|
+
# 自动打开浏览器 → 完成公司 SSO 授权 → token 写入本地配置
|
|
65
71
|
```
|
|
66
72
|
|
|
73
|
+
**账号密码登录**(仅管理员 / 服务账号):
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
artdam login --password --username <用户名>
|
|
77
|
+
# 回车后提示输入密码(不回显)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
| 参数 | 说明 |
|
|
81
|
+
|---|---|
|
|
82
|
+
| `--url` | 服务器地址(默认已内置,无需填写) |
|
|
83
|
+
| `--password` | 切换为账号密码模式(不加此 flag 默认走 SSO) |
|
|
84
|
+
| `--username` | 用户名(仅 `--password` 模式) |
|
|
85
|
+
|
|
67
86
|
#### `artdam search`
|
|
68
87
|
|
|
69
88
|
搜索资产,返回匹配列表。
|
|
70
89
|
|
|
71
90
|
```bash
|
|
72
|
-
artdam search "
|
|
73
|
-
artdam search "
|
|
74
|
-
artdam search "
|
|
75
|
-
artdam search "
|
|
76
|
-
artdam search "
|
|
77
|
-
artdam search "
|
|
91
|
+
artdam search "场景" # 使用默认项目
|
|
92
|
+
artdam search "场景" --project 1 # 临时指定项目
|
|
93
|
+
artdam search "场景" --limit 50
|
|
94
|
+
artdam search "场景" --type image/png
|
|
95
|
+
artdam search "场景" --folder 10
|
|
96
|
+
artdam search "场景" --json # 输出原始 JSON(AI Agent 用)
|
|
78
97
|
```
|
|
79
98
|
|
|
80
99
|
| 参数 | 说明 |
|
|
@@ -215,8 +234,8 @@ artdam folders --json
|
|
|
215
234
|
### 典型 Agent 工作流
|
|
216
235
|
|
|
217
236
|
```bash
|
|
218
|
-
# 1.
|
|
219
|
-
artdam login
|
|
237
|
+
# 1. 登录(SSO 浏览器授权,完成后自动保存 token)
|
|
238
|
+
artdam login
|
|
220
239
|
|
|
221
240
|
# 2. 查询项目列表,选择目标项目并设为默认
|
|
222
241
|
artdam projects --json
|
|
@@ -253,7 +272,7 @@ artdam update <asset_id> --description "AI 生成的场景描述"
|
|
|
253
272
|
|
|
254
273
|
```json
|
|
255
274
|
{
|
|
256
|
-
"base_url": "https://artdam.
|
|
275
|
+
"base_url": "https://artdam.xindong.com",
|
|
257
276
|
"token": "eyJ...",
|
|
258
277
|
"default_project": 1
|
|
259
278
|
}
|
|
@@ -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)
|
|
@@ -1,41 +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)
|
|
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)
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
import io
|
|
2
|
+
import sys
|
|
3
|
+
|
|
1
4
|
import click
|
|
2
5
|
|
|
6
|
+
# Windows 终端默认 GBK,强制 UTF-8 避免中文乱码
|
|
7
|
+
if hasattr(sys.stdout, "buffer") and sys.stdout.encoding.lower() not in ("utf-8", "utf-8-sig"):
|
|
8
|
+
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
|
|
9
|
+
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding="utf-8", errors="replace")
|
|
10
|
+
|
|
3
11
|
from artdam_cli.commands.login import login
|
|
4
12
|
from artdam_cli.commands.search import search
|
|
5
13
|
from artdam_cli.commands.get import get
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: artdam-cli
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: ArtDAM 数字资产管理平台命令行工具
|
|
5
5
|
Requires-Python: >=3.10
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -25,8 +25,11 @@ pip install artdam-cli
|
|
|
25
25
|
## 快速开始
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
#
|
|
29
|
-
artdam login
|
|
28
|
+
# 登录(默认走 SSO,自动打开浏览器完成授权)
|
|
29
|
+
artdam login
|
|
30
|
+
|
|
31
|
+
# 用账号密码登录
|
|
32
|
+
artdam login --password --username <用户名>
|
|
30
33
|
|
|
31
34
|
# 查看可访问的项目列表(获取项目 ID)
|
|
32
35
|
artdam projects
|
|
@@ -70,21 +73,37 @@ artdam project show # 查看当前默认项目
|
|
|
70
73
|
|
|
71
74
|
登录 ArtDAM,保存 token 到本地 `~/.artdam/config.json`。
|
|
72
75
|
|
|
76
|
+
**默认走 SSO 浏览器授权**(推荐):
|
|
77
|
+
|
|
73
78
|
```bash
|
|
74
|
-
artdam login
|
|
79
|
+
artdam login
|
|
80
|
+
# 自动打开浏览器 → 完成公司 SSO 授权 → token 写入本地配置
|
|
75
81
|
```
|
|
76
82
|
|
|
83
|
+
**账号密码登录**(仅管理员 / 服务账号):
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
artdam login --password --username <用户名>
|
|
87
|
+
# 回车后提示输入密码(不回显)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
| 参数 | 说明 |
|
|
91
|
+
|---|---|
|
|
92
|
+
| `--url` | 服务器地址(默认已内置,无需填写) |
|
|
93
|
+
| `--password` | 切换为账号密码模式(不加此 flag 默认走 SSO) |
|
|
94
|
+
| `--username` | 用户名(仅 `--password` 模式) |
|
|
95
|
+
|
|
77
96
|
#### `artdam search`
|
|
78
97
|
|
|
79
98
|
搜索资产,返回匹配列表。
|
|
80
99
|
|
|
81
100
|
```bash
|
|
82
|
-
artdam search "
|
|
83
|
-
artdam search "
|
|
84
|
-
artdam search "
|
|
85
|
-
artdam search "
|
|
86
|
-
artdam search "
|
|
87
|
-
artdam search "
|
|
101
|
+
artdam search "场景" # 使用默认项目
|
|
102
|
+
artdam search "场景" --project 1 # 临时指定项目
|
|
103
|
+
artdam search "场景" --limit 50
|
|
104
|
+
artdam search "场景" --type image/png
|
|
105
|
+
artdam search "场景" --folder 10
|
|
106
|
+
artdam search "场景" --json # 输出原始 JSON(AI Agent 用)
|
|
88
107
|
```
|
|
89
108
|
|
|
90
109
|
| 参数 | 说明 |
|
|
@@ -225,8 +244,8 @@ artdam folders --json
|
|
|
225
244
|
### 典型 Agent 工作流
|
|
226
245
|
|
|
227
246
|
```bash
|
|
228
|
-
# 1.
|
|
229
|
-
artdam login
|
|
247
|
+
# 1. 登录(SSO 浏览器授权,完成后自动保存 token)
|
|
248
|
+
artdam login
|
|
230
249
|
|
|
231
250
|
# 2. 查询项目列表,选择目标项目并设为默认
|
|
232
251
|
artdam projects --json
|
|
@@ -263,7 +282,7 @@ artdam update <asset_id> --description "AI 生成的场景描述"
|
|
|
263
282
|
|
|
264
283
|
```json
|
|
265
284
|
{
|
|
266
|
-
"base_url": "https://artdam.
|
|
285
|
+
"base_url": "https://artdam.xindong.com",
|
|
267
286
|
"token": "eyJ...",
|
|
268
287
|
"default_project": 1
|
|
269
288
|
}
|
|
@@ -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")
|
|
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
|
|
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
|