Class: Sloc::CLI
- Inherits:
-
Object
- Object
- Sloc::CLI
- Defined in:
- lib/sloc/cli.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
(also: #help)
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #help? ⇒ Boolean
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #parse_options(args) ⇒ Object
- #report(args = ARGV) ⇒ Object
- #run(args = ARGV) ⇒ Object
- #setup(args) ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
6 7 8 |
# File 'lib/sloc/cli.rb', line 6 def initialize @options = {} end |
Instance Attribute Details
#options ⇒ Object (readonly) Also known as: help
Returns the value of attribute options.
46 47 48 |
# File 'lib/sloc/cli.rb', line 46 def @options end |
Instance Method Details
#help? ⇒ Boolean
49 50 51 |
# File 'lib/sloc/cli.rb', line 49 def help? @paths.empty? || @options[:help] end |
#parse_options(args) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/sloc/cli.rb', line 35 def (args) opts = Slop.parse!(args) do |o| o.on('-h', '--help', 'Display this help message.') o.on('-o', '--order=', 'Specify key to order by.') o.on('--desc', 'Reverse order if specified') o.on('-l', '--limit=', 'Specify key to set limitation of displaying file number.') end [opts, args] end |
#report(args = ARGV) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/sloc/cli.rb', line 19 def report(args = ARGV) setup(args) if help? help else @runner.report(@paths) end end |
#run(args = ARGV) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/sloc/cli.rb', line 10 def run(args = ARGV) setup(args) if help? puts help else puts @runner.run(@paths) end end |