Module: Csso::CLI
- Defined in:
- lib/csso/cli.rb
Overview
:nodoc
Class Method Summary collapse
Class Method Details
.run!(argv = ARGV) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/csso/cli.rb', line 10 def self.run!(argv = ARGV) maniac = false opts = OptionParser.new do |opts| # rubocop:disable Lint/ShadowingOuterLocalVariable opts.version = Csso::VERSION opts. = "CSS Optimizer (ruby bindings by vasfed) version #{opts.version}" opts.separator '' opts.separator 'Usage:' opts.separator " #{opts.program_name} [options] FILE [FILE2 [FILE3 [...]]" opts.separator " #{opts.program_name} [options] < some_file.css" opts.separator '' opts.separator 'All input files are concatenated and fed to stdout after processing.' opts.separator '' opts.separator 'Options:' opts.on('-m', '--[no-]maniac', '"Maniac mode" optimizes input multiple times until optimization stops to give any results.') do |v| maniac = v end opts.on_tail('-v', '--version', 'Print version information') do return puts opts.ver end opts.on_tail('-h', '--help', 'Show this message') do return puts opts.help end end opts.parse!(argv) return puts opts.help if $stdin.tty? && argv.empty? ARGV.replace(argv) css = ARGF.read puts Csso.optimize(css, maniac) end |