# coding: utf-8 module Dag module CLI class Db < SubCommand desc 'list', 'Show database list' def list fields = %w(name) rows = handle_api_failure { open_client.databases } terminal_table(rows, fields: fields) end desc 'create [DATABASE]', 'Create database' def create(db_name) database = handle_api_failure do open_client.create_database(db_name) end say_status "Create Database", database.name end desc 'delete [DATABASE]', 'Delete database' def delete(db_name) db = '' handle_api_failure do db = open_client.database(db_name) db.delete if db end if db say_status "Delete Database", db_name else say_status "Unknown Database", db_name, :red end end end end end