Class: Cello::Commands::Main

Inherits:
Object
  • Object
show all
Defined in:
lib/cello/commands/main.rb

Class Method Summary collapse

Class Method Details

.run(args = ARGV) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/cello/commands/main.rb', line 5

def run(args=ARGV)
  cmd = args.shift

  case cmd
  when "-h", "--help", NilClass
    Cello::Commands::Help.run
    exit 0
  when "-v", "--version", "version"
    Cello::Commands::Version.run
    exit 0
  when "-np", "--new-project", "newproject"
    Cello::Commands::NewProject.run
    exit 0
  when "-nP", "--new-page", "newpage"
    Cello::Commands::NewPage.run
    exit 0
  when "-d", "--debug", "debug"
    Cello::Commands::Debug.run
    exit 0
  end

  unless system("cello #{cmd}", *args)
    if $?.exitstatus == 127 # bash 'command not found'
      puts "Unknown subcommand #{cmd.inspect}"
      Cello::Commands::Help.run
      exit 127
    end
  end
end