Module: Tidyup::Runner
- Defined in:
- lib/tidyup/runner.rb
Class Method Summary collapse
Class Method Details
.help ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/tidyup/runner.rb', line 42 def help maxn = .transpose.first.map(&:size).max maxd = .transpose.last .map(&:size).max "Usage: tidyup [file ...]\n" + .map{ |(name, desc)| if desc.empty? name else sprintf(" %-*s %-*s", maxn, name, maxd, desc) end }.join("\n") end |
.options ⇒ Object
5 6 7 8 9 |
# File 'lib/tidyup/runner.rb', line 5 def @options ||= [['-h, --help' , 'Print this message'], ['-v, --version' , 'Print the version' ]] end |
.parse(argv) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/tidyup/runner.rb', line 22 def parse argv paths = [] until argv.empty? case arg = argv.shift when /^-h/, '--help' puts(help) exit when /^-v/, '--version' require 'tidyup/version' puts(Tidyup::VERSION) exit else paths << arg end end paths end |