Class: Charming::CLI
- Inherits:
-
Object
- Object
- Charming::CLI
- Defined in:
- lib/charming/cli.rb
Overview
CLI dispatches the charming executable's subcommands to the appropriate generators
or database commands. Subcommands:
charming new NAME [--database sqlite3] [--force]— scaffolds a new appcharming generate TYPE NAME [args]— runs a sub-generator (controller, model, screen, view, component)charming generate layout [--style sidebar]— restores the sidebar/theme/palette app chromecharming db:COMMAND— runs a database command (db:create, db:migrate, db:rollback, db:drop, db:seed, db:install)
Generator errors are caught and printed to stderr; the process exits with status 1.
Defined Under Namespace
Classes: ConsoleContext
Instance Method Summary collapse
-
#call(argv) ⇒ Object
Runs the CLI with the given argv array.
-
#initialize(out: $stdout, err: $stderr, pwd: Dir.pwd) ⇒ CLI
constructor
out defaults to
$stdout, err to$stderr, pwd toDir.pwd(overridable for tests).
Constructor Details
#initialize(out: $stdout, err: $stderr, pwd: Dir.pwd) ⇒ CLI
out defaults to $stdout, err to $stderr, pwd to Dir.pwd (overridable for tests).
14 15 16 17 18 |
# File 'lib/charming/cli.rb', line 14 def initialize(out: $stdout, err: $stderr, pwd: Dir.pwd) @out = out @err = err @pwd = pwd end |
Instance Method Details
#call(argv) ⇒ Object
Runs the CLI with the given argv array. Returns 0 on success, 1 on a generator error,
or the status from usage for unknown subcommands.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/charming/cli.rb', line 22 def call(argv) command, *args = argv case command when "new" then new_app(args) when "generate", "g" then generate(args) when "console", "c" then console(args) when /^db:/ then database(command, args) else usage(1) end rescue Generators::Error => e err.puts e. 1 end |