Sha256: c9cf13b9d7fd6b1ec02b09a5ad0d943abfa9559b215366c16078dc256eeca679

Contents?: true

Size: 1.59 KB

Versions: 15

Compression:

Stored size: 1.59 KB

Contents

require 'opener/core'

module Opener
  class PropertyTagger
    ##
    # CLI wrapper around {Opener::PropertyTagger} using OptionParser.
    #
    # @!attribute [r] parser
    #  @return [Slop]
    #
    class CLI
      attr_reader :parser

      def initialize
        @parser = configure_slop
      end

      ##
      # @param [Array] argv
      #
      def run(argv = ARGV)
        parser.parse(argv)
      end

      ##
      # @return [Slop]
      #
      def configure_slop
        return Slop.new(:strict => false, :indent => 2, :help => true) do
          banner 'Usage: property-tagger [OPTIONS] -- [PYTHON OPTIONS]'

          separator <<-EOF.chomp

About:

    Component for finding the properties in a KAF document. This command reads
    input from STDIN.

Examples:

    Processing a KAF file:

        cat some_file.kaf | property-tagger

    Displaying the underlying kernel options:

        property-tagger -- --help

          EOF

          separator "\nOptions:\n"

          on :v, :version, 'Shows the current version' do
            abort "property-tagger v#{VERSION} on #{RUBY_DESCRIPTION}"
          end

          on :'no-time', 'Disables adding of timestamps'

          on :ugly, 'Disables pretty formatting of XML (faster)'

          run do |opts, args|
            tagger = PropertyTagger.new(
              :args    => args,
              :no_time => opts[:'no-time'],
              :pretty  => !opts[:ugly]
            )

            input  = STDIN.tty? ? nil : STDIN.read

            puts tagger.run(input)
          end
        end
      end
    end # CLI
  end # PropertyTagger
end # Opener

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
opener-property-tagger-3.4.3 lib/opener/property_tagger/cli.rb
opener-property-tagger-3.4.2 lib/opener/property_tagger/cli.rb
opener-property-tagger-3.4.1 lib/opener/property_tagger/cli.rb
opener-property-tagger-3.4.0 lib/opener/property_tagger/cli.rb
opener-property-tagger-3.3.6 lib/opener/property_tagger/cli.rb
opener-property-tagger-3.3.5 lib/opener/property_tagger/cli.rb
opener-property-tagger-3.3.4 lib/opener/property_tagger/cli.rb
opener-property-tagger-3.3.3 lib/opener/property_tagger/cli.rb
opener-property-tagger-3.3.2 lib/opener/property_tagger/cli.rb
opener-property-tagger-3.3.1 lib/opener/property_tagger/cli.rb
opener-property-tagger-3.2.1 lib/opener/property_tagger/cli.rb
opener-property-tagger-3.2.0 lib/opener/property_tagger/cli.rb
opener-property-tagger-3.1.1 lib/opener/property_tagger/cli.rb
opener-property-tagger-3.1.0 lib/opener/property_tagger/cli.rb
opener-property-tagger-3.0.6 lib/opener/property_tagger/cli.rb