{"size": 1526, "ext": "js", "max_stars_repo_path": "cli.js", "max_stars_repo_name": "Hackafe/meetups", "max_stars_repo_stars_event_min_datetime": "2017-01-04T13:44:28.000Z", "max_stars_repo_stars_event_max_datetime": "2017-01-11T12:20:26.000Z", "max_issues_repo_path": "cli.js", "max_issues_repo_name": "Hackafe/meetups", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "cli.js", "max_forks_repo_name": "Hackafe/meetups", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.3461538462, "max_line_length": 127, "alphanum_fraction": 0.6749672346}
#!/usr/bin/env node

var DISCOURSE_URL = 'https://frm.hackafe.org'
global.CMD_NAME = 'hackafe-meetups'

var optimist = require('optimist')
var rc = require('rc')

process.title = global.CMD_NAME
var argv = rc(global.CMD_NAME, { url: DISCOURSE_URL }, optimist
  .usage('Usage: $0 command [options]')
  .alias('h', 'host').describe('h', 'url of discourse instance').default('h', DISCOURSE_URL).string('h')
  .alias('k', 'apikey').describe('k', 'api key from ' + DISCOURSE_URL + '/admin/api').string('k')
  .alias('u', 'username').describe('u', 'username to execute operations').default('u', 'system').string('u')
  .alias('f', 'dry-run').describe('f', 'don\'t make any changes, just print what would do').boolean('f')
  .describe('version', 'prints current version').boolean('boolean')
  .argv)

if (argv.version) {
  var pkg = require('./package')
  console.error(pkg.name, pkg.version)
  process.exit(0)
}

var command = argv._[ 0 ]

if (!command) {
  optimist.showHelp()
  process.exit(1)
}

if (!argv.host || !argv.apikey || !argv.username) {
  optimist.showHelp()
  console.error('host, apikey and username options are required. They can be specified in a ~/.' + global.CMD_NAME + 'rc file')
  process.exit(1)
}

var Discourse = require('discourse-api')
var frm = new Discourse(argv.host, argv.apikey, argv.username)

var commandHandler
try {
  commandHandler = require('./cmd/' + command)
} catch (e) {
  console.error('Unknown command ' + command)
  process.exit(2)
}

require('./lib/helpers')

commandHandler(argv, frm)
