Sha256: c2eef5bc63d9ce150f8680a7d2550e0e5b331eaf4fabcbe864525438d3f1c48f
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
# frozen_string_literal: true require 'trollop' require 'prolog/dry_types' require_relative './trollop/option_spec' require_relative './trollop/options_and_mods' require_relative './trollop/validator' module ArticleFixtureGen module Exe module Trollop # Parse command-line options using Trollop. Note that Trollop is one-shot # stateful; it is apparently not possible to reset/rewind status once a # command line has been parsed without writing directly to ARGV. class OptionParser def self.call option_data = OptionsAndMods.call Internals.all_specs Internals.result_from option_data end # Stateless methods module Internals # NOTE: This is only "direct" user of `OptionSpec`, which is only # direct user of `OptionSpecItem`. def self.all_specs YAML.load_file 'data/all_specs.yml' end def self.result_from(option_data) # validate(option_data) Validator.call option_data Result.new modified: option_data.modified, options: option_data.options end end private_constant :Internals # Encapsulates active and modified command-line option data. class Result < Dry::Struct attribute :modified, Types::Hash attribute :options, Types::Hash end private_constant :Result end # class ArticleFixtureGen::Exe::Trollop::OptionParser end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
article_fixture_gen-0.1.2 | lib/article_fixture_gen/exe/option_parser/trollop.rb |
article_fixture_gen-0.1.1 | lib/article_fixture_gen/exe/option_parser/trollop.rb |