Method: Milkode::Cdstk#setdb

Defined in:
lib/milkode/cdstk/cdstk.rb

#setdb(args, options) ⇒ Object



683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
# File 'lib/milkode/cdstk/cdstk.rb', line 683

def setdb(args, options)
  if (options[:reset])
    CdstkCommand.setdb_reset
    @out.puts "Reset default db\n  remove:      #{Dbdir.milkode_db_dir}\n  default_db:  #{Dbdir.default_dir}"
  elsif (args.empty?)
    @out.puts Dbdir.default_dir
  else
    dbpath = args.first
    path = File.expand_path(dbpath)
    begin
      CdstkCommand.setdb_set path
      @out.puts "Set default db #{path}."
    rescue CdstkCommand::NotExistDatabase
      @out.puts "fatal: '#{path}' is not database."
    end
  end
end