Ticket #464 (closed enhancement: duplicate)

Opened 11 months ago

Last modified 10 months ago

[PATCH] Improve merb command line API, help

Reported by: kev..@centropy.com Assigned to:
Priority: major Milestone: The Future
Component: Merb Keywords:
Cc:

Description

I rewrote the merb command to be cleaner, more sane and extendable.

The benefits are: * a much cleaner command line API * sets user expectations of what options apply to which commands * eliminates illogical possibilities, e.g., what happens if a user specifes both --webrick and --fastcgi * Removal of the convoluted 230-line "parse_args" method * "commands" such as generate or run-script are clearly differentiated from "options" * Detailed help is available for each command and subcommand * Additional commands and subcommands could be added by plugins * Options and arguments are firmly validated * merb [project] (the one-arg project generator) still works * merb (no-arg server starter) still works

--- $ merb --help Merb Mongrel+ Erb. Lightweight replacement for ActionPack?. ******************************************************************************** If no flags are given, Merb starts in the foreground on port 4000. ******************************************************************************** Usage: merb [global options] COMMAND [options] [arguments]

Available commands:

console Start merb in irb console mode. generate Generate a fresh merb application or plugin.

application Generate a merb application. plugin Generate a merb plugin.

help Provide help for individual commands script Run scripts and/or code in the merb app. start Start merb application (=default command) stop Stop merb application version

Global options:

-M, --merb-config FILENAME This flag is for explicitly declaring the merb app's config file. -m, --merb-root MERB_ROOT The path to the Merb.root for the app you want to run (default is current working dir). -f, --config-file FILENAME This flag is for adding extra config files for things like the upload progress module. -l, --log-level LEVEL Log levels can be set to any of these options: DEBUG < INFO < WARN < ERROR < FATAL < UNKNOWN -e, --environment STRING Run merb in the correct mode(development, production, testing) -h, --help Show help

---

Get help on each command: --- $ merb help start start: Start merb application Start merb application as a single node or a cluster of nodes.

Usage: merb start [options]

Options for start:

-u, --user USER This flag is for having merb run as a user other than the one currently logged in. Note: if you set this you must also provide a --group option for it to take effect. -G, --group GROUP This flag is for having merb run as a group other than the one currently logged in. Note: if you set this you must also provide a --user option for it to take effect. -p, --port PORTNUM Port to run merb on, defaults to 4000. -s, --start-drb PORTNUM This is the port number to run the drb daemon on for sessions and upload progress monitoring. -A, --adapter RACK_ADAPTER Specify which Rack server adapter to use. -d, --[no-]daemonize This will run a single merb in the background. -c, --cluster-nodes NUM_MERBS Number of merb daemons to run. -h, --host HOSTNAME Host to bind to (default is all IP's). -D, --debugger Run merb using rDebug.

---

This syntax works for subcommands, and we also get "partial command" capability: --- $ merb help gen app application: Generate a merb application. Generate a fresh merb application.

Usage: merb generate application PATH ---

Attachments

merb_cli.diff (30.0 kB) - added by kev..@centropy.com on 01/17/08 09:52:48.
Patch for merb command line interface

Change History

01/17/08 09:52:48 changed by kev..@centropy.com

  • attachment merb_cli.diff added.

Patch for merb command line interface

01/17/08 09:53:56 changed by kev..@centropy.com

  • summary changed from Improve merb command line API, help to [PATCH] Improve merb command line API, help.

01/17/08 09:56:03 changed by kev..@centropy.com

$ merb --help
Merb Mongrel+ Erb. Lightweight replacement for ActionPack.
********************************************************************************
If no flags are given, Merb starts in the foreground on port 4000.
********************************************************************************
Usage: merb [global options] COMMAND [options] [arguments]

Available commands:
  console        Start merb in irb console mode.
  generate       Generate a fresh merb application or plugin.
    application    Generate a merb application.
    plugin         Generate a merb plugin.
  help           Provide help for individual commands
  script         Run scripts and/or code in the merb app.
  start          Start merb application (=default command)
  stop           Stop merb application
  version        

Global options:
    -M, --merb-config FILENAME       This flag is for explicitly declaring the merb app's config file.
    -m, --merb-root MERB_ROOT        The path to the Merb.root for the app you want to run (default is current working dir).
    -f, --config-file FILENAME       This flag is for adding extra config files for things like the upload progress module.
    -l, --log-level LEVEL            Log levels can be set to any of these options: DEBUG < INFO < WARN < ERROR < FATAL < UNKNOWN
    -e, --environment STRING         Run merb in the correct mode(development, production, testing)
    -h, --help                       Show help
---

Get help on each command:
---
$ merb help start
start: Start merb application
Start merb application as a single node or a cluster of nodes.

Usage: merb start [options]

Options for start:
    -u, --user USER                  This flag is for having merb run as a user other than the one currently logged in. Note: if you set this you must also provide a --group option for it to take effect.
    -G, --group GROUP                This flag is for having merb run as a group other than the one currently logged in. Note: if you set this you must also provide a --user option for it to take effect.
    -p, --port PORTNUM               Port to run merb on, defaults to 4000.
    -s, --start-drb PORTNUM          This is the port number to run the drb daemon on for sessions and upload progress monitoring.
    -A, --adapter RACK_ADAPTER       Specify which Rack server adapter to use.
    -d, --[no-]daemonize             This will run a single merb in the background.
    -c, --cluster-nodes NUM_MERBS    Number of merb daemons to run.
    -h, --host HOSTNAME              Host to bind to (default is all IP's).
    -D, --debugger                   Run merb using rDebug.
---

This syntax works for subcommands, and we also get "partial command" capability:
---
$ merb help gen app
application: Generate a merb application.
Generate a fresh merb application.

Usage: merb generate application PATH
---

01/18/08 12:25:14 changed by kev..@centropy.com

(Benefits reformatted...)

The benefits are:

  • a much cleaner command line API
  • sets user expectations of what options apply to which commands
  • eliminates illogical possibilities, e.g., what happens if a user specifes both --webrick and --fastcgi
  • Removal of the convoluted 230-line "parse_args" method
  • "commands" such as generate or run-script are clearly differentiated from "options"
  • Detailed help is available for each command and subcommand
  • Additional commands and subcommands could be added by plugins
  • Options and arguments are firmly validated
  • merb [project] (the one-arg project generator) still works
  • merb (no-arg server starter) still works

02/11/08 13:39:24 changed by shayarne..@gmail.com

  • status changed from new to closed.
  • resolution set to duplicate.