Class: CodeSync::Cli::Base
- Inherits:
-
Thor
- Object
- Thor
- CodeSync::Cli::Base
show all
- Defined in:
- lib/code_sync/cli.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/code_sync/cli.rb', line 52
def method_missing(meth, *args)
meth = meth.to_s
if self.class.map.has_key?(meth)
meth = self.class.map[meth]
end
klass, task = Thor::Util.find_class_and_task_by_namespace("#{meth}:#{meth}")
if klass.nil?
super
else
args.unshift(task) if task
klass.start(args, :shell => self.shell)
end
end
|
Class Method Details
.start(*args) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/code_sync/cli.rb', line 9
def start(*args)
ARGV.unshift("help") if ARGV.delete("--help")
if ARGV[0] != "help" && (ARGV.length < 1 || ARGV.first.include?("-"))
ARGV.unshift("server")
end
super
end
|
Instance Method Details
#help(meth = nil, subcommand = false) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/code_sync/cli.rb', line 28
def help(meth = nil, subcommand = false)
if meth && !self.respond_to?(meth)
klass, task = Thor::Util.find_class_and_task_by_namespace("#{meth}:#{meth}")
klass.start(["-h", task].compact, :shell => self.shell)
else
list = []
Thor::Util.thor_classes_in(CodeSync::Cli).each do |klass|
list += klass.printable_tasks(false)
end
list.sort!{ |a,b| a[0] <=> b[0] }
shell.say "Tasks:"
shell.print_table(list, :ident => 2, :truncate => true)
shell.say
end
end
|
#start ⇒ Object
48
49
50
|
# File 'lib/code_sync/cli.rb', line 48
def start
CodeSync::Manager.start(root: options[:root])
end
|
#version ⇒ Object
23
24
25
26
|
# File 'lib/code_sync/cli.rb', line 23
def version
require 'luca/version'
say "CodeSync #{CodeSync::Version}"
end
|