Sha256: c9428c6c9880fe953c2badf9b39091a64de8b89822926a44747e44744bd2af4c
Contents?: true
Size: 1 KB
Versions: 1
Compression:
Stored size: 1 KB
Contents
# frozen_string_literal: true module Ruboclean # Reads command line arguments and exposes corresponding reader methods class CliArguments def initialize(command_line_arguments = []) @command_line_arguments = Array(command_line_arguments) end def path @path ||= find_path end def verbose? !silent? end def silent? @silent ||= find_argument("--silent") end def preserve_comments? @preserve_comments ||= find_argument("--preserve-comments") end def preserve_paths? @preserve_paths ||= find_argument("--preserve-paths") end def verify? @verify ||= find_argument("--verify") end private attr_reader :command_line_arguments def find_path command_line_arguments.first.then do |argument| return Dir.pwd if argument.nil? || argument.start_with?("--") argument end end def find_argument(name) command_line_arguments.any? { |argument| argument == name } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruboclean-0.6.0 | lib/ruboclean/cli_arguments.rb |