Class: Ichiban::Command
- Inherits:
-
Object
- Object
- Ichiban::Command
- Defined in:
- lib/ichiban/command.rb
Instance Method Summary collapse
-
#initialize(args, dev = false) ⇒ Command
constructor
A new instance of Command.
- #print_usage ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(args, dev = false) ⇒ Command
Returns a new instance of Command.
3 4 5 6 7 |
# File 'lib/ichiban/command.rb', line 3 def initialize(args, dev = false) @task = args.shift @args = args @dev = dev end |
Instance Method Details
#print_usage ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ichiban/command.rb', line 9 def print_usage puts( "\nUsage: ichiban [command]\n" + "Available commands: \n" + " watch\n" + " compile [-a] [path]\n" + " new [path]\n" + " help\n\n" + "https://github.com/jarrett/ichiban\n\n" ) end |
#run ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ichiban/command.rb', line 21 def run case @task when 'watch' Ichiban.project_root = Dir.getwd Ichiban::Watcher.new.start when 'compile' Ichiban.project_root = Dir.getwd compiler = Ichiban::ManualCompiler.new if @args.first == '-a' compiler.all else compiler.paths @args end when 'new' Ichiban::ProjectGenerator.new( File.(@args[0]) ).generate Ichiban.logger.out "Initialized Ichiban project in #{@args[0]}" when 'version', '-v', '--version' puts "Ichiban version #{::Ichiban::VERSION}" else print_usage end end |