Class: Strata::CLI::SubCommands::Table

Inherits:
Thor
  • Object
show all
Extended by:
Helpers::DescriptionHelper
Includes:
Guard, Helpers::CommandContext, Prompts, Terminal, Thor::Actions
Defined in:
lib/strata/cli/sub_commands/table.rb

Constant Summary

Constants included from DatasourceHelper

DatasourceHelper::ADAPTER_DRIVER_GEMS

Constants included from Prompts

Prompts::MIGRATION_HOOK_OPTIONS, Prompts::MSG_CONTINUE_NO_FIELDS, Prompts::MSG_CREATED_MODEL, Prompts::MSG_EDIT_MODEL_HINT, Prompts::MSG_FIELDS_CONFIRMED, Prompts::MSG_JOIN_CONDITION, Prompts::MSG_MODELS_COUNT, Prompts::MSG_MODELS_LIST_HEADER, Prompts::MSG_MODEL_DESCRIPTION, Prompts::MSG_MODEL_DISPLAY_NAME, Prompts::MSG_NO_FIELDS_CONFIRMED, Prompts::MSG_NO_MODELS_DIR, Prompts::MSG_NO_MODELS_FOUND, Prompts::MSG_NO_TABLES_FOUND, Prompts::MSG_RELATION_PATH, Prompts::MSG_SEARCH_TABLE, Prompts::MSG_SELECT_FROM_LIST, Prompts::MSG_SELECT_LEFT_TABLE, Prompts::MSG_SELECT_RIGHT_TABLE_ALL, Prompts::MSG_SELECT_RIGHT_TABLE_SUGGESTED, Prompts::MSG_SHOW_OTHER_TABLES

Constants included from Guard

Guard::ALLOWED_COMMANDS

Instance Method Summary collapse

Methods included from Helpers::DescriptionHelper

long_desc_from_file

Methods included from Helpers::CommandContext

#adapter, #all_tables, #datasource_key, #prompt, #table_fetch_result

Methods included from DatasourceHelper

#apply_readonly_mode, #create_adapter, #ds_config, #ensure_adapter_driver_gems!, #load_adapter_driver_gems!, #resolve_datasource, #resolve_datasource_value

Methods included from Prompts

default_migration_hook

Methods included from Terminal

#create_spinner, #print_table, #with_spinner

Methods included from Guard

#invoke_command

Instance Method Details

#listObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/strata/cli/sub_commands/table.rb', line 19

def list
  unless Dir.exist?("models")
    say MSG_NO_MODELS_DIR, :yellow
    return
  end

  model_files = Dir.glob("models/tbl[._]*.yml").sort

  if model_files.empty?
    say MSG_NO_MODELS_FOUND, :yellow
    return
  end

  say MSG_MODELS_LIST_HEADER, :cyan

  model_files.each do |file|
    display_model_item(file)
  end

  say MSG_MODELS_COUNT % model_files.length, :cyan
end