#!/usr/bin/env node 'use strict'; require('supererror'); require('colors'); var program = require('commander'), appstoreActions = require('../src/appstore-actions.js'); program.version(require('../package.json').version); program.command('login') .description('Login to the appstore') .option('-e, --email ', 'Email address') .option('-p, --password ', 'Password (unsafe)') .action(appstoreActions.login); program.command('logout') .description('Logout from the appstore') .action(appstoreActions.logout); program.command('info') .description('List info of published app') .option('--appstore-id ', 'Appstore id and version') .action(appstoreActions.info); program.command('published') .description('List published apps from this account') .option('-i --image', 'Display docker image') .action(appstoreActions.listPublishedApps); program.command('approve') .description('Approve a submitted app version') .option('--appstore-id ', 'Appstore id and version') .action(appstoreActions.approve); program.command('revoke') .description('Revoke a published app version') .option('--appstore-id ', 'Appstore id and version') .action(appstoreActions.revoke); program.command('submit') .description('Submit app to the store for review') .action(appstoreActions.submit); program.command('unpublish') .description('Delete app or app version from the store') .option('--appstore-id ', 'Unpublish app') .option('-f, --force', 'Do not ask anything') .action(appstoreActions.unpublish); program.command('upload') .description('Upload app to the store for testing') .option('-i, --image ', 'Docker image') .option('-f, --force', 'Update existing version') .action(appstoreActions.upload); program.command('versions') .description('List published versions') .option('--appstore-id ', 'Appstore id') .option('--raw', 'Dump versions as json') .action(appstoreActions.listVersions); if (!process.argv.slice(2).length) { program.outputHelp(); } else { // https://github.com/tj/commander.js/issues/338 // deal first with global flags! program.parse(process.argv); if (process.argv[2] === 'help') { return program.outputHelp(); } var knownCommand = program.commands.some(function (command) { return command._name === process.argv[2] || command._alias === process.argv[2]; }); if (!knownCommand) { console.log('Unknown command: ' + process.argv[2].bold + '.\nTry ' + 'cloudron appstore help'.yellow); process.exit(1); } return; } program.parse(process.argv);