gd-utils/dedupe

25 lines
824 B
Plaintext
Raw Normal View History

2020-06-27 14:19:43 +08:00
#!/usr/bin/env node
const { argv } = require('yargs')
2020-07-07 19:15:49 +08:00
.usage('用法: ./$0 <folder-id> [options]')
2020-06-27 14:19:43 +08:00
.alias('u', 'update')
.describe('u', '不使用本地缓存,强制从线上获取源文件夹信息')
.alias('S', 'service_account')
.describe('S', '使用service account进行操作前提是必须在 ./sa 目录下放置sa授权json文件')
.help('h')
.alias('h', 'help')
const { dedupe, validate_fid } = require('./src/gd')
const [fid] = argv._
if (validate_fid(fid)) {
const { update, service_account } = argv
dedupe({ fid, update, service_account }).then(info => {
if (!info) return
const { file_count, folder_count } = info
console.log('任务完成,共删除文件数:', file_count, '目录数:', folder_count)
})
} else {
console.warn('目录ID缺失或格式错误')
}