UNPKG

alia

Version:
39 lines (38 loc) 939 B
import { Flag } from './flag.js'; export class SyncFlag extends Flag { flag = { key: 'sync', short: 'sy', desc: 'backup/restore config from gist (default: restore)', run: (_, data) => this.#sync(data) }; mods = [ { key: 'backup', short: 'b', desc: 'backup your current config', run: () => this.#backup() }, { key: 'restore', short: 'r', desc: 'restore latest config from gist', run: () => this.#restore() } ]; async #sync(data) { if (data && Object.keys(data).length > 0) { return true; } await this.#restore(); return true; } async #restore() { await this.gistService.restore(); return true; } async #backup() { await this.gistService.backup(); return true; } }