     fragments_APPLICATION factory
 
 module.exports.command_serve.$help = "[server-callback-name (default: 'server')] - start a server with server-callback-name as callback"
-
-module.exports.command_info = (
-  fragments_APPLICATION
-) ->
-  fragments_APPLICATION (
-    fragments_console
-  ) ->
-    (args...) ->
-      fragments_console.log 'TODO'
-      fragments_console.log 'OK'

    commandNames = _.sortBy(commandNames)

    commandNames.map (name) ->
      key = fragments_commandNameToFactoryPropertyName name
      line = name
      docstring = lifetime.factories[key].$help
      if docstring?
        line += ' ' + docstring
      return line

module.exports.command_help = (
  fragments_getCommandHelpLinesFromLifetime
  fragments_applicationLifetime
) ->
  (args...) ->
    fragments_getCommandHelpLinesFromLifetime(fragments_applicationLifetime, args...).forEach (line) ->
      console.log line
module.exports.command_help.$help = '[namespace-prefixes...] display available commands'


module.exports.fragments_commandPrefix = ->
  'command_'

module.exports.fragments_getCommandNames = (
  fragments_helfer
  fragments_commandPrefix
  fragments_source
) ->
  ->
    keys = fragments_source.keys?() or []
    keys
      .filter (x) -> x.indexOf(fragments_commandPrefix) is 0
      .map (x) -> x.slice(fragments_commandPrefix.length)
      .map fragments_helfer.camelSnakeToHyphenColon

module.exports.fragments_commandNameToKey = (
  fragments_helfer
  fragments_commandPrefix
) ->
  (name) ->
    fragments_commandPrefix + fragments_helfer.hyphenColonToCamelSnake(name)

module.exports.fragments_getCommand = (
  fragments_Promise
  fragments_hinoki
  fragments_commandNameToKey
  fragments_source
  fragments_applicationLifetime
) ->
  (commandName) ->
    commandKey = fragments_commandNameToKey(commandName.toLowerCase())
    commandFactory = fragments_source(commandKey)

    unless commandFactory?
      return

    (args...) ->
      fragments_hinoki(fragments_source, fragments_applicationLifetime, commandKey)
        .then (commandInstance) ->
          commandInstance args...

module.exports.fragments_runCommand = (
  fragments_getCommand
  fragments_source
) ->
  (commandName, args...) ->
    unless commandName?
      commandName = 'help'
    command = fragments_getCommand(commandName)
    if command?
      command args...
    else
      throw new Error "no such command: #{commandName}"

module.exports.fragments_getCommandHelpLines = (
  fragments_getCommandNames
  fragments_commandNameToKey
  fragments_isjs
  fragments_lodash
  fragments_source
) ->
  (lifetime, args...) ->
    _ = fragments_lodash
    commandNames = fragments_getCommandNames()
    # help for a specific command or namespace is requested
    if args.length isnt 0
      prefix = args.join(':')
