Class: Strata::CLI::SubCommands::Create
- Inherits:
-
Thor
- Object
- Thor
- Strata::CLI::SubCommands::Create
- Extended by:
- Helpers::DescriptionHelper
- Includes:
- AgentMode, Guard, Helpers::CommandContext, Prompts, Terminal, Thor::Actions
- Defined in:
- lib/strata/cli/sub_commands/create.rb
Constant Summary
Constants included from DatasourceHelper
DatasourceHelper::ADAPTER_DRIVER_GEMS
Constants included from Output
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_POLICY_BYPASS_ADMIN, Prompts::MSG_POLICY_BYPASS_PROJECT, Prompts::MSG_POLICY_CONTEXT_DIM, Prompts::MSG_POLICY_CREATED, Prompts::MSG_POLICY_FIELD_NAMES, Prompts::MSG_POLICY_FIELD_TAGS, Prompts::MSG_POLICY_HINT, Prompts::MSG_POLICY_MASK_VALUE, Prompts::MSG_POLICY_MODE, Prompts::MSG_POLICY_NAME, Prompts::MSG_POLICY_PERM_SOURCE, Prompts::MSG_POLICY_TAG_KEY, Prompts::MSG_POLICY_VALUE_FROM, 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
Instance Method Summary collapse
- #migration(subcommand) ⇒ Object
- #migration_rename ⇒ Object
- #migration_swap ⇒ Object
- #policy(name = nil) ⇒ Object
- #relation(relation_path) ⇒ Object
- #table(table_path = nil) ⇒ Object
Methods included from Helpers::DescriptionHelper
Methods included from AgentMode
#agent_mode?, included, #reject_agent_mode!
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 Output
format, pastel, print_error, #print_error, print_hint, #print_hint, print_info, #print_info, print_status, #print_status, print_success, #print_success, print_warning, #print_warning, shell_for, thor_color
Methods included from Prompts
Methods included from Terminal
#create_spinner, #print_table, #with_spinner
Methods included from Guard
Instance Method Details
#migration(subcommand) ⇒ Object
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/strata/cli/sub_commands/create.rb', line 95 def migration(subcommand) case subcommand when "rename" migration_rename when "swap" migration_swap else raise Strata::CommandError, "Unknown migration subcommand: #{subcommand}. Use 'rename' or 'swap'." end end |
#migration_rename ⇒ Object
114 115 116 117 118 119 120 |
# File 'lib/strata/cli/sub_commands/create.rb', line 114 def migration_rename validate_entity_type([:entity], "rename") validate_required_params([:entity], [:from], [:to]) hook = prompt_migration_hook("rename") create_rename_migration([:entity], [:from], [:to], hook) end |
#migration_swap ⇒ Object
130 131 132 133 134 135 136 |
# File 'lib/strata/cli/sub_commands/create.rb', line 130 def migration_swap validate_entity_type([:entity], "swap") validate_required_params([:entity], [:from], [:to]) hook = prompt_migration_hook("swap") create_swap_migration([:entity], [:from], [:to], hook) end |
#policy(name = nil) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/strata/cli/sub_commands/create.rb', line 61 def policy(name = nil) attrs = policy_interactive_mode? ? collect_policy_interactive(name) : collect_policy_fast(name) require_relative "../generators/policy" Generators::Policy.new([attrs]).invoke_all say MSG_POLICY_CREATED % attrs[:name], :green say MSG_POLICY_HINT, :yellow end |
#relation(relation_path) ⇒ Object
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/strata/cli/sub_commands/create.rb', line 75 def relation(relation_path) reject_agent_mode!( "Agent mode: write models/rel.*.yml directly.", code: "use_yaml_files" ) return unless datasource_key create_relation_file(relation_path) end |
#table(table_path = nil) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/strata/cli/sub_commands/create.rb', line 38 def table(table_path = nil) reject_agent_mode!( "Agent mode: write models/tbl.*.yml directly. Use: strata datasource meta DS_KEY TABLE_NAME --agent", code: "use_yaml_files" ) return unless datasource_key # If table_path provided, skip search for speed if table_path handle_table_creation_with_path(table_path) else handle_table_creation_interactive end end |