Sha256: f957867c39ff5813b4b0d76b8db6206f186f0bbe731fa54a5e368f39b6894288
Contents?: true
Size: 1.45 KB
Versions: 6
Compression:
Stored size: 1.45 KB
Contents
# frozen_string_literal: true require "refinements/structs" module Milestoner module CLI module Parsers # Handles parsing of Command Line Interface (CLI) security options. class Security using Refinements::Structs def self.call(...) = new(...).call def initialize configuration = Container[:configuration], client: Parser::CLIENT, container: Container @configuration = configuration @client = client @container = container end def call arguments = [] client.separator "\nSECURITY OPTIONS:\n" add_sign client.parse arguments configuration end private attr_reader :configuration, :client, :container def add_sign client.on( "--[no-]sign", %(Sign with GPG key. Default: #{configuration.sign}.) ) do |value| compute_sign value end end def compute_sign value truth_table = [true, false].repeated_permutation(2).to_a case truth_table.index [value, configuration.sign] when 0..1 then configuration.merge! sign: true when 2..3 then configuration.merge! sign: false else logger.error { "--sign must be a boolean. Check gem configuration." } end end def logger = container[__method__] end end end end
Version data entries
6 entries across 6 versions & 1 rubygems