aardio 文档
aardio 范例: 无窗体、无输入等待;直接运行,只查询公开仓库,不需要 token。
// 无窗体、无输入等待;直接运行,只查询公开仓库,不需要 token。
import web.rest.github;
var gh = web.rest.github;
var repo = "octocat/Spoon-Knife";
// 1. 看目录:默认最多 50 项,可同时限定输出字节数。
var listing,err = gh.list(repo,{maxResults=10;maxBytes=2000});
if(!listing) { print(err); return null,err; }
print("目录",JSON.stringify(listing));
// 2. 找源码路径:一次文件树请求,不逐个下载正文。
var files;
files,err = gh.findFiles(repo,"*.html|*.css",{maxResults=10;maxBytes=2000});
if(!files) { print(err); return null,err; }
print("文件",JSON.stringify(files));
// 3. 已知文件直接读;pattern 默认是字面子串,不需要转义尖括号。
var excerpt;
excerpt,err = gh.read(repo,"index.html",{
pattern = "<body>";
context = 4;
maxBytes = 1600;
});
if(!excerpt) { print(err); return null,err; }
print(excerpt.data);
// 按行预览:gh.read(repo,"index.html",{startLine=1;lineCount=20;maxBytes=2000})
// 文件 URL:gh.read("https://github.com/octocat/Spoon-Knife/blob/main/index.html")
// 继续阅读:把 excerpt.nextLine 放进 options.startLine(有 pattern 则继续搜索)。
// 读完与否:read 的 complete=true 才表示 data 已是整个文件;要全文直接 gh.getContent("octocat","Spoon-Knife","index.html")。
// 官方端点:gh.repo(repo).commits.get({per_page=3}),与官方 API 同名同参数。
// complete=false 时未命中不代表不存在;不要将截断结果当成完整仓库。
// 不要调用需认证的 search.code;全仓正文搜索用联网搜索或下载仓库后本地搜索。
return {listing=listing;files=files;excerpt=excerpt};
Markdown 格式