Sha256: 50ab1bc63a4cd29a3bce31dfdb1847c173ac1783753681125b9aa8bff0cfe6b2
Contents?: true
Size: 1.11 KB
Versions: 8
Compression:
Stored size: 1.11 KB
Contents
require "optparse" module SCSSBeautifier class Options attr_reader :options def initialize @options = {} @option_parser = OptionParser.new do |opts| opts.version = SCSSBeautifier::VERSION add_banner(opts) add_config_option(opts) add_in_place_option(opts) end end def parse(args) @option_parser.parse!(args) options[:path] = args.first if args.first options end private def add_banner(opts) opts.banner = unindent(<<-BANNER) Beautify your SCSS code Usage: #{opts.program_name} [options] [path] BANNER end def add_config_option(opts) message = "the configuration file" opts.on("-c", "--config config", message, String) do |config| self.options[:config] = config end end def add_in_place_option(opts) message = "whether to overwrite the file or not" opts.on("-i", "--in-place", message) do |bool| self.options[:in_place] = bool end end def unindent(str) str.gsub(/^#{str.scan(/^[ ]+(?=\S)/).min}/, "") end end end
Version data entries
8 entries across 8 versions & 1 rubygems