Sha256: 9c72cbe131edceac21f0700d6166ad922d35e9d278b1c10f4da9d6e5013be329

Contents?: true

Size: 1.26 KB

Versions: 11

Compression:

Stored size: 1.26 KB

Contents

#encofing: utf-8

require 'optparse'

module Csso
  module CLI
    def self.run!(argv=ARGV)
      maniac = false
      opts = OptionParser.new do |opts|
        opts.version = Csso::VERSION
        opts.banner = "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)

      if $stdin.tty? && argv.empty?
        return puts opts.help
      end

      ARGV.replace(argv)
      css = ARGF.read
      puts Csso.optimize(css, maniac)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
csso-rails-0.8.2 lib/csso/cli.rb
csso-rails-0.8.1 lib/csso/cli.rb
csso-rails-0.8.0 lib/csso/cli.rb
csso-rails-0.7.1 lib/csso/cli.rb
csso-rails-0.7.0 lib/csso/cli.rb
csso-rails-0.6.0 lib/csso/cli.rb
csso-rails-0.5.0 lib/csso/cli.rb
csso-rails-0.4.1 lib/csso/cli.rb
csso-rails-0.4.0 lib/csso/cli.rb
csso-rails-0.3.4 lib/csso/cli.rb
csso-rails-0.3.3 lib/csso/cli.rb