Sha256: 760c32d8b92b8594e4dffea4386186a2f78a61b0ac648e95ba009ded9c92cc21

Contents?: true

Size: 1.09 KB

Versions: 19

Compression:

Stored size: 1.09 KB

Contents

require 'pathname'
require 'erb'
require 'find'
require 'pp'
require 'optparse'
require 'yaml'

require 'bitclust'
require 'bitclust/subcommand'

module BitClust
  module Subcommands
    class InitCommand < Subcommand
      def initialize
        super
        @parser.banner = "Usage: #{File.basename($0, '.*')} init [KEY=VALUE ...]"
      end

      STANDARD_PROPERTIES = %w( encoding version )

      def exec(argv, options)
        prefix = options[:prefix]
        db = MethodDatabase.new(prefix)
        db.init
        db.transaction {
          argv.each do |kv|
            k, v = kv.split('=', 2)
            db.propset k, v
          end
        }
        fail = false
        STANDARD_PROPERTIES.each do |key|
          unless db.propget(key)
            $stderr.puts "#{File.basename($0, '.*')}: warning: standard property `#{key}' not given"
            fail = true
          end
        end
        if fail
          $stderr.puts "---- Current Properties ----"
          db.properties.each do |key, value|
            $stderr.puts "#{key}=#{value}"
          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/init_command.rb
bitclust-core-1.2.5 lib/bitclust/subcommands/init_command.rb
bitclust-core-1.2.4 lib/bitclust/subcommands/init_command.rb
bitclust-core-1.2.3 lib/bitclust/subcommands/init_command.rb
bitclust-core-1.2.2 lib/bitclust/subcommands/init_command.rb
bitclust-core-1.2.1 lib/bitclust/subcommands/init_command.rb
bitclust-core-1.2.0 lib/bitclust/subcommands/init_command.rb
bitclust-core-1.1.1 lib/bitclust/subcommands/init_command.rb
bitclust-core-1.1.0 lib/bitclust/subcommands/init_command.rb
bitclust-core-1.0.0 lib/bitclust/subcommands/init_command.rb
bitclust-core-0.9.6 lib/bitclust/subcommands/init_command.rb
bitclust-core-0.9.5 lib/bitclust/subcommands/init_command.rb
bitclust-core-0.9.4 lib/bitclust/subcommands/init_command.rb
bitclust-core-0.9.3 lib/bitclust/subcommands/init_command.rb
bitclust-core-0.9.2 lib/bitclust/subcommands/init_command.rb
bitclust-core-0.9.1 lib/bitclust/subcommands/init_command.rb
bitclust-core-0.9.0 lib/bitclust/subcommands/init_command.rb
bitclust-core-0.8.0 lib/bitclust/subcommands/init_command.rb
bitclust-core-0.7.0 lib/bitclust/subcommands/init_command.rb