Sha256: e8708cfe63db2057f6492e91a297d7fdde8796d40692d29d1c225a6049a41778

Contents?: true

Size: 1.36 KB

Versions: 19

Compression:

Stored size: 1.36 KB

Contents

require 'pathname'
require 'optparse'

require 'bitclust'
require 'bitclust/subcommand'

module BitClust
  module Subcommands
    class ExtractCommand < Subcommand

      def initialize
        super
        @parser.banner = "Usage: #{File.basename($0, '.*')} <file>..."
        @parser.on('-c', '--check-only', 'Check syntax and output status.') {
          @check_only = true
        }
      end

      def exec(argv, options)
        success = true
        argv.each do |path|
          begin
            lib = RRDParser.parse_stdlib_file(path)
            if @check_only
              $stderr.puts "#{path}: OK"
            else
              show_library lib
            end
          rescue WriterError => err
            raise if $DEBUG
            $stderr.puts "#{File.basename($0, '.*')}: FAIL: #{err.message}"
            success = false
          end
        end
        exit success
      end

      def show_library(lib)
        puts "= Library #{lib.name}"
        lib.classes.each do |c|
          puts "#{c.type} #{c.name}"
          c.each do |m|
            puts "\t* #{m.klass.name}#{m.typemark}#{m.names.join(',')}"
          end
        end
        unless lib.methods.empty?
          puts "Additional Methods:"
          lib.methods.each do |m|
            puts "\t* #{m.klass.name}#{m.typemark}#{m.names.join(',')}"
          end
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
bitclust-core-1.2.6 lib/bitclust/subcommands/extract_command.rb
bitclust-core-1.2.5 lib/bitclust/subcommands/extract_command.rb
bitclust-core-1.2.4 lib/bitclust/subcommands/extract_command.rb
bitclust-core-1.2.3 lib/bitclust/subcommands/extract_command.rb
bitclust-core-1.2.2 lib/bitclust/subcommands/extract_command.rb
bitclust-core-1.2.1 lib/bitclust/subcommands/extract_command.rb
bitclust-core-1.2.0 lib/bitclust/subcommands/extract_command.rb
bitclust-core-1.1.1 lib/bitclust/subcommands/extract_command.rb
bitclust-core-1.1.0 lib/bitclust/subcommands/extract_command.rb
bitclust-core-1.0.0 lib/bitclust/subcommands/extract_command.rb
bitclust-core-0.9.6 lib/bitclust/subcommands/extract_command.rb
bitclust-core-0.9.5 lib/bitclust/subcommands/extract_command.rb
bitclust-core-0.9.4 lib/bitclust/subcommands/extract_command.rb
bitclust-core-0.9.3 lib/bitclust/subcommands/extract_command.rb
bitclust-core-0.9.2 lib/bitclust/subcommands/extract_command.rb
bitclust-core-0.9.1 lib/bitclust/subcommands/extract_command.rb
bitclust-core-0.9.0 lib/bitclust/subcommands/extract_command.rb
bitclust-core-0.8.0 lib/bitclust/subcommands/extract_command.rb
bitclust-core-0.7.0 lib/bitclust/subcommands/extract_command.rb