25 lines
842 B
JavaScript
Executable File
25 lines
842 B
JavaScript
Executable File
#!/usr/bin/env node
|
||
|
||
const { argv } = require('yargs')
|
||
.usage('用法: ./$0 <folder-id> [options]')
|
||
.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或格式錯誤')
|
||
}
|