clamp-1.3.3/0000755000004100000410000000000015045240442012642 5ustar www-datawww-dataclamp-1.3.3/.autotest0000644000004100000410000000036115045240442014513 0ustar www-datawww-datarequire "autotest/bundler" Autotest.add_hook :initialize do |at| at.add_exception ".git" at.add_mapping(%r{^lib/(.*)\.rb$}, :prepend) do |_, match| ["spec/unit/#{match[1]}_spec.rb"] + Dir['spec/clamp/command*_spec.rb'] end end clamp-1.3.3/.editorconfig0000644000004100000410000000025115045240442015315 0ustar www-datawww-dataroot = true [*] indent_style = space indent_size = 2 end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true max_line_length = 120 clamp-1.3.3/.gitignore0000644000004100000410000000012115045240442014624 0ustar www-datawww-data*.gem .bundle .markdownlint* .rvmrc .ruby-version .yardoc doc pkg/* Gemfile.lock clamp-1.3.3/CHANGES.md0000644000004100000410000000366515045240442014246 0ustar www-datawww-data# Changelog ## 1.3.3 (2025-07-31) * Raise an error if no value is provided for a non-flag switch. ## 1.3.2 (2020-08-20) * Fix Ruby warnings. ## 1.3.1 (2019-07-11) * Choose a sensible column width in generated help, based on content. * Fix issue#99: extraneous parameter names in subcommand help. ## 1.3.0 (2018-06-17) * Add `.execute` DSL method. * Append '(required)' to the description of required options. * Fix issue#75: don't generate `default_XXX` method unless a default is specified. * Fix issue#90: allow required options to be provided after subcommands. ## 1.2.0 (2018-02-12) * Add option to `Clamp.allow_options_after_parameters`. ## 1.1.2 (2017-02-12) * Improve usage help for commands with both parameters and subcommands. ## 1.1.1 (2016-10-19) * Rename `.declare_attribute` back to `.define_accessors_for`. ## 1.1.0 (2016-10-17) * Add `#subcommand_missing`. * Fix issue#66: pass parameter values down to nested subcommands. * Drop support for Ruby 1.9 and 2.0. ## 1.0.1 (2016-10-01) * Minor bug-fixes. ## 1.0.0 (2015-06-08) * Allow options to be `:hidden`. * I18N support. ## 0.6.5 (2015-05-02) * Catch signals and exit appropriately. ## 0.6.4 (2015-02-26) * Ensure computed defaults are only computed once. ## 0.6.3 (2013-11-14) * Specify (MIT) license. ## 0.6.2 (2013-11-06) * Refactoring around multi-valued attributes. * Allow injection of a custom help-builder. ## 0.6.1 (2013-05-07) * Signal a usage error when an environment_variable fails validation. * Refactor setting, defaulting and inheritance of attributes. ## 0.6.0 (2013-04-28) * Introduce "banner" to describe a command (replacing "self.description="). * Introduce "Clamp do ... end" syntax sugar. * Allow parameters to be specified before a subcommand. * Add support for :multivalued options. * Multi valued options and parameters get an "#append_to_foo_list" method, rather than "#foo_list=". * default_subcommand must be specified before any subcommands. clamp-1.3.3/clamp.gemspec0000644000004100000410000000150515045240442015304 0ustar www-datawww-data# frozen_string_literal: true $LOAD_PATH.push File.expand_path("lib", __dir__) require "clamp/version" Gem::Specification.new do |s| s.name = "clamp" s.version = Clamp::VERSION.dup s.platform = Gem::Platform::RUBY s.authors = ["Mike Williams"] s.email = "mdub@dogbiscuit.org" s.homepage = "https://github.com/mdub/clamp" s.license = "MIT" s.summary = "a minimal framework for command-line utilities" s.description = <<-TEXT.gsub(/^\s+/, "") Clamp provides an object-model for command-line utilities. It handles parsing of command-line options, and generation of usage help. TEXT s.files = `git ls-files`.split("\n") s.require_paths = ["lib"] s.required_ruby_version = ">= 2.5", "< 4" s.metadata["rubygems_mfa_required"] = "true" end clamp-1.3.3/Guardfile0000644000004100000410000000276715045240442014503 0ustar www-datawww-data# frozen_string_literal: true # A sample Guardfile # More info at https://github.com/guard/guard#readme ## Uncomment and set this to only include directories you want to watch # directories %w(app lib config test spec features) \ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")} ## NOTE: if you are using the `directories` clause above and you are not ## watching the project directory ('.'), then you will want to move ## the Guardfile to a watched dir and symlink it back, e.g. # # $ mkdir config # $ mv Guardfile config/ # $ ln -s config/Guardfile . # # and, you'll have to watch "config/Guardfile" instead of "Guardfile" # NOTE: The cmd option is now required due to the increasing number of ways # rspec may be run, below are examples of the most common uses. # * bundler: 'bundle exec rspec' # * bundler binstubs: 'bin/rspec' # * spring: 'bin/rspec' (This will use spring if running and you have # installed the spring binstubs per the docs) # * zeus: 'zeus rspec' (requires the server to be started separately) # * 'just' rspec: 'rspec' guard :rspec, cmd: "bundle exec rspec" do require "guard/rspec/dsl" dsl = Guard::RSpec::Dsl.new(self) # Feel free to open issues for suggestions and improvements # RSpec files rspec = dsl.rspec watch(rspec.spec_helper) { rspec.spec_dir } watch(rspec.spec_support) { rspec.spec_dir } watch(rspec.spec_files) # Ruby files ruby = dsl.ruby dsl.watch_spec_files_for(ruby.lib_files) end clamp-1.3.3/lib/0000755000004100000410000000000015045240442013410 5ustar www-datawww-dataclamp-1.3.3/lib/clamp/0000755000004100000410000000000015045240442014504 5ustar www-datawww-dataclamp-1.3.3/lib/clamp/messages.rb0000644000004100000410000000257515045240442016651 0ustar www-datawww-data# frozen_string_literal: true module Clamp # :nodoc: # Message lookup, to allow localization. # module Messages def messages=(new_messages) messages.merge!(new_messages) end def message(key, options = {}) string = messages.fetch(key) return string if options.empty? format string, options end def clear_messages! init_default_messages end DEFAULTS = { too_many_arguments: "too many arguments", option_required: "option '%