Class: BitClust::Subcommands::InitCommand
- Inherits:
-
BitClust::Subcommand
- Object
- BitClust::Subcommand
- BitClust::Subcommands::InitCommand
- Defined in:
- lib/bitclust/subcommands/init_command.rb
Constant Summary collapse
- STANDARD_PROPERTIES =
%w( encoding version )
Instance Method Summary collapse
- #exec(argv, options) ⇒ Object
-
#initialize ⇒ InitCommand
constructor
A new instance of InitCommand.
Methods inherited from BitClust::Subcommand
#align_progress_bar_title, #error, #help, #option_error, #parse, #srcdir_root
Constructor Details
#initialize ⇒ InitCommand
Returns a new instance of InitCommand.
15 16 17 18 |
# File 'lib/bitclust/subcommands/init_command.rb', line 15 def initialize super @parser. = "Usage: #{File.basename($0, '.*')} init [KEY=VALUE ...]" end |
Instance Method Details
#exec(argv, options) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/bitclust/subcommands/init_command.rb', line 22 def exec(argv, ) prefix = [: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 |