@shift-code/cli
Version:
Redeem Gearbox SHiFT codes automatically
92 lines • 2.69 kB
JavaScript
#!/usr/bin/env node
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const yargs_1 = __importDefault(require("yargs"));
const migrate_1 = require("./cache/migrate");
const commands_1 = require("./commands");
const names_1 = require("./names");
const runCommand = (fn) => (args) => {
fn(args)
.catch((err) => {
console.log(err);
});
};
void async function () {
await (0, migrate_1.migrateOldCache)();
yargs_1.default
.command({
command: 'login',
describe: 'Login to a new account',
handler: runCommand(commands_1.loginCommand),
builder: {
email: {
alias: 'e'
},
password: {
alias: 'p'
}
}
})
.command({
command: 'logout',
describe: 'Logout of current account, or specified account',
handler: runCommand(commands_1.logoutCommand),
builder: {
email: {
alias: 'e'
}
}
})
.command({
command: 'accounts',
describe: 'Show all accounts, marking the currently active account',
handler: runCommand(commands_1.accountCommand)
})
.command({
command: 'cache <command>',
describe: 'Manage cached Shift codes',
handler: () => { },
builder: (yargs) => yargs
.command({
command: 'clear',
describe: 'Clear code cache for current account, or specified account',
handler: runCommand(commands_1.cacheCommand),
builder: {
email: {
alias: 'e'
}
}
})
})
.command({
command: 'redeem [codes...]',
describe: 'Redeem all available codes or the given codes if provided',
handler: runCommand(commands_1.redeemCommand),
builder: {
game: {
alias: 'g',
array: true,
choices: Object.keys(names_1.GameName)
},
platform: {
alias: 'p',
array: true,
choices: Object.keys(names_1.PlatformName)
},
file: {
alias: 'f',
type: 'string',
description: 'Path to a file containing codes to redeem'
}
}
})
.help()
.version()
.demandCommand()
.strict()
.argv;
}();
//# sourceMappingURL=bin.js.map