Class: Rouge::CLI
- Inherits:
-
Object
show all
- Defined in:
- lib/rouge/cli.rb
Defined Under Namespace
Classes: Debug, Error, Guess, Help, Highlight, List, Style, Version
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ CLI
Returns a new instance of CLI.
89
90
|
# File 'lib/rouge/cli.rb', line 89
def initialize(options={})
end
|
Class Method Details
.class_from_arg(arg) ⇒ Object
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
# File 'lib/rouge/cli.rb', line 100
def self.class_from_arg(arg)
case arg
when 'version', '--version', '-v'
Version
when 'help', nil
Help
when 'highlight', 'hi'
Highlight
when 'debug'
Debug
when 'style'
Style
when 'list'
List
when 'guess'
Guess
end
end
|
.doc {|%|usage: rougify {global options} [command] [args...]|| ... } ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/rouge/cli.rb', line 40
def self.doc
return enum_for(:doc) unless block_given?
yield %|usage: rougify {global options} [command] [args...]|
yield %||
yield %|where <command> is one of:|
yield %| highlight #{Highlight.desc}|
yield %| debug #{Debug.desc}|
yield %| help #{Help.desc}|
yield %| style #{Style.desc}|
yield %| list #{List.desc}|
yield %| guess #{Guess.desc}|
yield %| version #{Version.desc}|
yield %||
yield %|global options:|
yield %[ --require|-r <fname> require <fname> after loading rouge]
yield %||
yield %|See `rougify help <command>` for more info.|
end
|
.error!(msg, status = 1) ⇒ Object
92
93
94
|
# File 'lib/rouge/cli.rb', line 92
def self.error!(msg, status=1)
raise Error.new(msg, status)
end
|
.parse(argv = ARGV) ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/rouge/cli.rb', line 68
def self.parse(argv=ARGV)
argv = normalize_syntax(argv)
while (head = argv.shift)
case head
when '-h', '--help', 'help', '-help'
return Help.parse(argv)
when '--require', '-r'
require argv.shift
else
break
end
end
klass = class_from_arg(head)
return klass.parse(argv) if klass
argv.unshift(head) if head
Highlight.parse(argv)
end
|
Instance Method Details
#error!(*a) ⇒ Object
96
97
98
|
# File 'lib/rouge/cli.rb', line 96
def error!(*a)
self.class.error!(*a)
end
|