Sha256: 438524fb5ad098b9b40ff2e87d6c18ee44a5a149a47f15c477a4dde87f040999

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

# encofing: utf-8

require 'optparse'

module Csso
  # :nodoc
  module CLI
    def self.run!(argv = ARGV)
      maniac = false
      opts = OptionParser.new do |opts| # rubocop:disable Lint/ShadowingOuterLocalVariable
        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)

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
csso-rails-1.0.0 lib/csso/cli.rb
csso-rails-0.9.0 lib/csso/cli.rb