diff --git a/src/apm-cli.coffee b/src/apm-cli.coffee index 9bd49d5..cc8bda6 100644 --- a/src/apm-cli.coffee +++ b/src/apm-cli.coffee @@ -26,41 +26,84 @@ setupTempDirectory = -> setupTempDirectory() -commandClasses = [ - require './ci' - require './clean' - require './config' - require './dedupe' - require './develop' - require './disable' - require './docs' - require './enable' - require './featured' - require './init' - require './install' - require './links' - require './link' - require './list' - require './login' - require './publish' - require './rebuild' - require './rebuild-module-cache' - require './search' - require './star' - require './stars' - require './test' - require './uninstall' - require './unlink' - require './unpublish' - require './unstar' - require './upgrade' - require './view' -] - -commands = {} -for commandClass in commandClasses - for name in commandClass.commandNames ? [] - commands[name] = commandClass +# TODO make loading lazy +ciClass = require './ci' +cleanClass = require './clean' +configClass = require './config' +dedupClass = require './dedupe' +developClass = require './develop' +disableClass = require './disable' +docsClass = require './docs' +enableClass = require './enable' +featuredClass = require './featured' +initClass = require './init' +installClass = require './install' +linksClass = require './links' +linkClass = require './link' +listClass = require './list' +loginClass = require './login' +publishClass = require './publish' +rebuildClass = require './rebuild' +rebuildModuleCacheClass = require './rebuild-module-cache' +searchClass = require './search' +starClass = require './star' +starsClass = require './stars' +testClass = require './test' +uninstallClass = require './uninstall' +unlinkClass = require './unlink' +unpublishClass = require './unpublish' +unstarClass = require './unstar' +upgradeClass = require './upgrade' +viewClass = require './view' + +commands = { + 'ci': ciClass, + 'clean': cleanClass, + 'prune': cleanClass, + 'config': configClass, + 'dedupe': dedupClass, + 'dev': developClass, + 'develop': developClass, + 'disable': disableClass, + 'docs': docsClass, + 'home': docsClass, + 'open': docsClass, + 'enable': enableClass + 'featured': featuredClass + 'init': initClass, + 'install': installClass, + 'i': installClass, + 'link': linkClass, + 'ln': linkClass + 'linked': linksClass, + 'links': linksClass, + 'lns': linksClass, + 'list': listClass, + 'ls': listClass, + 'login': loginClass, + 'publish': publishClass, + 'rebuild-module-cache': rebuildModuleCacheClass, + 'rebuild': rebuildClass, + 'search': searchClass, + 'star': starClass, + 'stars': starsClass, + 'starred': starsClass + 'test': testClass + 'deinstall': uninstallClass, + 'delete': uninstallClass, + 'erase': uninstallClass, + 'remove': uninstallClass, + 'rm': uninstallClass, + 'uninstall': uninstallClass, + 'unlink': unlinkClass, + 'unpublish': unpublishClass, + 'unstar': unstarClass, + 'upgrade': upgradeClass, + 'outdated': upgradeClass, + 'update': upgradeClass, + 'view': viewClass, + 'show': viewClass, +} parseOptions = (args=[]) -> options = yargs(args).wrap(Math.min(100, yargs.terminalWidth())) diff --git a/src/ci.coffee b/src/ci.coffee index ddf3970..59b8a24 100644 --- a/src/ci.coffee +++ b/src/ci.coffee @@ -9,8 +9,6 @@ Command = require './command' module.exports = class Ci extends Command - @commandNames: ['ci'] - constructor: -> super() @atomDirectory = config.getAtomDirectory() diff --git a/src/clean.coffee b/src/clean.coffee index 0a4f517..62e2d3b 100644 --- a/src/clean.coffee +++ b/src/clean.coffee @@ -11,8 +11,6 @@ fs = require './fs' module.exports = class Clean extends Command - @commandNames: ['clean', 'prune'] - constructor: -> super() @atomNpmPath = require.resolve('npm/bin/npm-cli') diff --git a/src/config.coffee b/src/config.coffee index 7bf1450..5dc448e 100644 --- a/src/config.coffee +++ b/src/config.coffee @@ -6,8 +6,6 @@ Command = require './command' module.exports = class Config extends Command - @commandNames: ['config'] - constructor: -> super() atomDirectory = apm.getAtomDirectory() diff --git a/src/dedupe.coffee b/src/dedupe.coffee index f430f1d..4edfcf9 100644 --- a/src/dedupe.coffee +++ b/src/dedupe.coffee @@ -10,8 +10,6 @@ fs = require './fs' module.exports = class Dedupe extends Command - @commandNames: ['dedupe'] - constructor: -> super() @atomDirectory = config.getAtomDirectory() diff --git a/src/develop.coffee b/src/develop.coffee index 4d4d353..5c1220c 100644 --- a/src/develop.coffee +++ b/src/develop.coffee @@ -14,8 +14,6 @@ request = require './request' module.exports = class Develop extends Command - @commandNames: ['dev', 'develop'] - constructor: -> super() @atomDirectory = config.getAtomDirectory() diff --git a/src/disable.coffee b/src/disable.coffee index 2107fef..71b1b31 100644 --- a/src/disable.coffee +++ b/src/disable.coffee @@ -9,8 +9,6 @@ List = require './list' module.exports = class Disable extends Command - @commandNames: ['disable'] - parseOptions: (argv) -> options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth())) options.usage """ diff --git a/src/docs.coffee b/src/docs.coffee index 1c7c862..064e53a 100644 --- a/src/docs.coffee +++ b/src/docs.coffee @@ -6,8 +6,6 @@ config = require './apm' module.exports = class Docs extends View - @commandNames: ['docs', 'home', 'open'] - parseOptions: (argv) -> options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth())) options.usage """ diff --git a/src/enable.coffee b/src/enable.coffee index 764b1f0..caed944 100644 --- a/src/enable.coffee +++ b/src/enable.coffee @@ -8,8 +8,6 @@ Command = require './command' module.exports = class Enable extends Command - @commandNames: ['enable'] - parseOptions: (argv) -> options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth())) options.usage """ diff --git a/src/featured.coffee b/src/featured.coffee index 413ba49..a65425c 100644 --- a/src/featured.coffee +++ b/src/featured.coffee @@ -8,8 +8,6 @@ tree = require './tree' module.exports = class Featured extends Command - @commandNames: ['featured'] - parseOptions: (argv) -> options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth())) options.usage """ diff --git a/src/init.coffee b/src/init.coffee index a711cf3..b633932 100644 --- a/src/init.coffee +++ b/src/init.coffee @@ -7,8 +7,6 @@ fs = require './fs' module.exports = class Init extends Command - @commandNames: ['init'] - supportedSyntaxes: ['coffeescript', 'javascript'] parseOptions: (argv) -> diff --git a/src/install.coffee b/src/install.coffee index 383d9f7..4fc73d2 100644 --- a/src/install.coffee +++ b/src/install.coffee @@ -19,8 +19,6 @@ request = require './request' module.exports = class Install extends Command - @commandNames: ['install', 'i'] - constructor: -> super() @atomDirectory = config.getAtomDirectory() diff --git a/src/link.coffee b/src/link.coffee index 502a3e2..1ce7698 100644 --- a/src/link.coffee +++ b/src/link.coffee @@ -9,8 +9,6 @@ fs = require './fs' module.exports = class Link extends Command - @commandNames: ['link', 'ln'] - parseOptions: (argv) -> options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth())) options.usage """ diff --git a/src/links.coffee b/src/links.coffee index 992bc03..0f330ea 100644 --- a/src/links.coffee +++ b/src/links.coffee @@ -9,8 +9,6 @@ tree = require './tree' module.exports = class Links extends Command - @commandNames: ['linked', 'links', 'lns'] - constructor: -> super() @devPackagesPath = path.join(config.getAtomDirectory(), 'dev', 'packages') diff --git a/src/list.coffee b/src/list.coffee index 95c882e..7c585bc 100644 --- a/src/list.coffee +++ b/src/list.coffee @@ -12,8 +12,6 @@ tree = require './tree' module.exports = class List extends Command - @commandNames: ['list', 'ls'] - constructor: -> super() @userPackagesDirectory = path.join(config.getAtomDirectory(), 'packages') diff --git a/src/login.coffee b/src/login.coffee index 6b6d369..2b53510 100644 --- a/src/login.coffee +++ b/src/login.coffee @@ -16,8 +16,6 @@ class Login extends Command else callback(null, token) - @commandNames: ['login'] - parseOptions: (argv) -> options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth())) diff --git a/src/publish.coffee b/src/publish.coffee index 1d20a6a..22d97a2 100644 --- a/src/publish.coffee +++ b/src/publish.coffee @@ -14,8 +14,6 @@ request = require './request' module.exports = class Publish extends Command - @commandNames: ['publish'] - constructor: -> super() @userConfigPath = config.getUserConfigPath() diff --git a/src/rebuild-module-cache.coffee b/src/rebuild-module-cache.coffee index 83565bb..b8c0a6f 100644 --- a/src/rebuild-module-cache.coffee +++ b/src/rebuild-module-cache.coffee @@ -7,8 +7,6 @@ fs = require './fs' module.exports = class RebuildModuleCache extends Command - @commandNames: ['rebuild-module-cache'] - constructor: -> super() @atomPackagesDirectory = path.join(config.getAtomDirectory(), 'packages') diff --git a/src/rebuild.coffee b/src/rebuild.coffee index 7094155..9172ddb 100644 --- a/src/rebuild.coffee +++ b/src/rebuild.coffee @@ -10,8 +10,6 @@ Install = require './install' module.exports = class Rebuild extends Command - @commandNames: ['rebuild'] - constructor: -> super() @atomDirectory = config.getAtomDirectory() diff --git a/src/search.coffee b/src/search.coffee index 2340be0..39813e1 100644 --- a/src/search.coffee +++ b/src/search.coffee @@ -9,8 +9,6 @@ tree = require './tree' module.exports = class Search extends Command - @commandNames: ['search'] - parseOptions: (argv) -> options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth())) options.usage """ diff --git a/src/star.coffee b/src/star.coffee index 0b817de..874bf32 100644 --- a/src/star.coffee +++ b/src/star.coffee @@ -14,8 +14,6 @@ request = require './request' module.exports = class Star extends Command - @commandNames: ['star'] - parseOptions: (argv) -> options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth())) options.usage """ diff --git a/src/stars.coffee b/src/stars.coffee index 95e9b18..37e70e3 100644 --- a/src/stars.coffee +++ b/src/stars.coffee @@ -10,8 +10,6 @@ tree = require './tree' module.exports = class Stars extends Command - @commandNames: ['stars', 'starred'] - parseOptions: (argv) -> options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth())) options.usage """ diff --git a/src/test.coffee b/src/test.coffee index cbe8ea9..aac5af4 100644 --- a/src/test.coffee +++ b/src/test.coffee @@ -8,8 +8,6 @@ fs = require './fs' module.exports = class Test extends Command - @commandNames: ['test'] - parseOptions: (argv) -> options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth())) diff --git a/src/uninstall.coffee b/src/uninstall.coffee index 60f3e86..a5f135d 100644 --- a/src/uninstall.coffee +++ b/src/uninstall.coffee @@ -12,8 +12,6 @@ request = require './request' module.exports = class Uninstall extends Command - @commandNames: ['deinstall', 'delete', 'erase', 'remove', 'rm', 'uninstall'] - parseOptions: (argv) -> options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth())) options.usage """ diff --git a/src/unlink.coffee b/src/unlink.coffee index 00dc65f..d25440d 100644 --- a/src/unlink.coffee +++ b/src/unlink.coffee @@ -9,8 +9,6 @@ fs = require './fs' module.exports = class Unlink extends Command - @commandNames: ['unlink'] - constructor: -> super() @devPackagesPath = path.join(config.getAtomDirectory(), 'dev', 'packages') diff --git a/src/unpublish.coffee b/src/unpublish.coffee index 2c48585..2bf51f8 100644 --- a/src/unpublish.coffee +++ b/src/unpublish.coffee @@ -11,8 +11,6 @@ request = require './request' module.exports = class Unpublish extends Command - @commandNames: ['unpublish'] - parseOptions: (argv) -> options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth())) diff --git a/src/unstar.coffee b/src/unstar.coffee index cb38d9f..3a900b5 100644 --- a/src/unstar.coffee +++ b/src/unstar.coffee @@ -8,8 +8,6 @@ request = require './request' module.exports = class Unstar extends Command - @commandNames: ['unstar'] - parseOptions: (argv) -> options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth())) options.usage """ diff --git a/src/upgrade.coffee b/src/upgrade.coffee index 5295ae2..96ed7e9 100644 --- a/src/upgrade.coffee +++ b/src/upgrade.coffee @@ -18,8 +18,6 @@ git = require './git' module.exports = class Upgrade extends Command - @commandNames: ['upgrade', 'outdated', 'update'] - constructor: -> super() @atomDirectory = config.getAtomDirectory() diff --git a/src/view.coffee b/src/view.coffee index 7a291dc..e48fdf4 100644 --- a/src/view.coffee +++ b/src/view.coffee @@ -9,8 +9,6 @@ tree = require './tree' module.exports = class View extends Command - @commandNames: ['view', 'show'] - parseOptions: (argv) -> options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth())) options.usage """