Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

v3 #265

Closed
wants to merge 2 commits into from

1 participant

@tombell

Coming soon(:tm:)...

@tombell tombell referenced this pull request
Closed

Ideas for hubot v3 #256

@tombell

I don't like this anymore, so going to close it and NUKE ALL THE THINGS.

@tombell tombell closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 28, 2012
  1. @tombell
Commits on Mar 29, 2012
  1. @tombell

    Update template procfile

    tombell authored
This page is out of date. Refresh to see the latest.
Showing with 46 additions and 81 deletions.
  1. +45 −80 bin/hubot
  2. +1 −1  src/templates/Procfile
View
125 bin/hubot
@@ -1,107 +1,72 @@
#!/usr/bin/env coffee
-# -*- mode:coffee -*-
-##
-# hubot [options]
-#
-# Launch an interactive hubot
#
# vim:ft=coffee ts=2 sw=2 et :
# -*- mode:coffee -*-
+App = require 'commander'
Hubot = require '..'
Fs = require 'fs'
Path = require 'path'
HTTP = require 'http'
Creator = require '../src/creator'
-OptParse = require 'optparse'
-
-Switches = [
- [ "-a", "--adapter ADAPTER", "The Adapter to use" ],
- [ "-c", "--create PATH", "Create a deployable hubot" ],
- [ "-d", "--disable-httpd", "Disable the HTTP server" ],
- [ "-h", "--help", "Display the help information" ],
- [ "-l", "--alias ALIAS", "Enable replacing the robot's name with alias" ],
- [ "-n", "--name NAME", "The name of the robot in chat" ],
- [ "-s", "--enable-slash", "Enable replacing the robot's name with '/' (deprecated)" ],
- [ "-v", "--version", "Displays the version of hubot installed" ]
-]
-
-Options =
- adapter: "shell"
- alias: false
- create: false
- enableHttpd: true
- name: "Hubot"
- path: "."
-
-Parser = new OptParse.OptionParser(Switches)
-Parser.banner = "Usage hubot [options]"
-
-Parser.on "adapter", (opt, value) ->
- Options.adapter = value
-
-Parser.on "create", (opt, value) ->
- Options.path = value
- Options.create = true
-
-Parser.on "disable-httpd", (opt) ->
- Options.enableHttpd = false
-
-Parser.on "help", (opt, value) ->
- console.log Parser.toString()
- process.exit 0
-Parser.on "alias", (opt, value) ->
- Options.alias = value
+contents = Fs.readFileSync __dirname + '/../package.json', 'utf8'
+App.version (JSON.parse contents).version
-Parser.on "name", (opt, value) ->
- Options.name = value
+App
+ .command('new [path]')
+ .description('Create a new deployable hubot')
+ .action (path) ->
+ creator = new Creator.Creator(path)
+ creator.run()
-Parser.on "enable-slash", (opt) ->
- console.log "WARNING: -s and --enable-slash are deprecated please use -l or --alias '/'"
- Options.alias = '/'
+App
+ .command('start [name]')
+ .description('Start a hubot instance')
-Parser.on "version", (opt, value) ->
- Options.version = true
+ .option('-a, --adapter [adapter]', 'adapter hubot will use')
+ .option('-d, --no-http', 'disable the built in HTTP server')
+ .option('-l, --alias [alias]', 'enable replacing the robot name with an alias')
-Parser.parse process.argv
+ .action (name, options) ->
+ name or= 'hubot'
-unless process.platform is "win32"
- process.on 'SIGTERM', ->
- process.exit 0
+ adapter = options.adapter or 'shell'
+ http = !!options.http
-if Options.create
- creator = new Creator.Creator(Options.path)
- creator.run()
+ console.log "HTTP: #{http}"
+ alias = options.alias or '/'
-else
- adapterPath = Path.resolve __dirname, "..", "src", "adapters"
+ adapterPath = Path.resolve __dirname, '..', 'src', 'adapters'
- robot = Hubot.loadBot adapterPath, Options.adapter, Options.enableHttpd, Options.name
+ robot = Hubot.loadBot adapterPath, adapter, http, name
- if Options.version
- console.log robot.version
- process.exit 0
+ robot.enableSlash = !!alias
+ robot.alias = alias
- robot.enableSlash = Options.enableSlash
- robot.alias = Options.alias
+ robot.adapter.on 'connected', ->
+ scriptsPath = Path.resolve '.', 'scripts'
+ robot.load scriptsPath
- loadScripts = ->
- scriptsPath = Path.resolve ".", "scripts"
- robot.load scriptsPath
+ scriptsPath = Path.resolve 'src', 'scripts'
+ robot.load scriptsPath
- scriptsPath = Path.resolve "src", "scripts"
- robot.load scriptsPath
+ scriptsFile = Path.resolve 'hubot-scripts.json'
+ Path.exists scriptsFile, (exists) =>
+ if exists
+ Fs.readFile scriptsFile, (err, data) ->
+ scripts = JSON.parse data
+ scriptsPath = Path.resolve 'node_modules', 'hubot-scripts', 'src', 'scripts'
+ robot.loadHubotScripts scriptsPath, scripts
- scriptsFile = Path.resolve "hubot-scripts.json"
- Path.exists scriptsFile, (exists) =>
- if exists
- Fs.readFile scriptsFile, (err, data) ->
- scripts = JSON.parse data
- scriptsPath = Path.resolve "node_modules", "hubot-scripts", "src", "scripts"
- robot.loadHubotScripts scriptsPath, scripts
+ robot.run()
- robot.adapter.on 'connected', loadScripts
+App.parse process.argv
- robot.run()
+if process.argv.length is 2
+ console.log App.helpInformation()
+ process.exit 0
+unless process.platform is 'win32'
+ process.on 'SIGTERM', ->
+ process.exit 0
View
2  src/templates/Procfile
@@ -1 +1 @@
-web: bin/hubot -a campfire -n Hubot
+web: bin/hubot start --adapter campfire hubot
Something went wrong with that request. Please try again.