Module: Belt::CLI
- Defined in:
- lib/belt/cli.rb,
lib/belt/cli/new_command.rb,
lib/belt/cli/env_resolver.rb,
lib/belt/cli/app_detection.rb,
lib/belt/cli/setup_command.rb,
lib/belt/cli/tasks_command.rb,
lib/belt/cli/views_command.rb,
lib/belt/cli/routes_command.rb,
lib/belt/cli/tables_command.rb,
lib/belt/cli/bucket_security.rb,
lib/belt/cli/frontend_command.rb,
lib/belt/cli/generate_command.rb,
lib/belt/cli/terraform_command.rb,
lib/belt/cli/environment_command.rb,
lib/belt/cli/frontend_setup_command.rb,
lib/belt/cli/frontend_deploy_command.rb,
lib/belt/cli/routes_command/schema_loader.rb,
lib/belt/cli/routes_command/route_inference.rb
Defined Under Namespace
Modules: AppDetection, BucketSecurity, EnvResolver
Classes: EnvironmentCommand, FrontendCommand, FrontendDeployCommand, FrontendSetupCommand, GenerateCommand, NewCommand, RoutesCommand, SetupCommand, TablesCommand, TasksCommand, TerraformCommand, ViewsCommand
Constant Summary
collapse
- COMMANDS_DEFINITION =
{
'new' => Belt::CLI::NewCommand,
%w[generate g] => Belt::CLI::GenerateCommand,
'routes' => Belt::CLI::RoutesCommand,
%w[tasks --tasks -T] => Belt::CLI::TasksCommand,
'setup' => Belt::CLI::SetupCommand,
'deploy' => lambda { |args|
subcommand = args.shift
if subcommand == 'frontend'
Belt::CLI::FrontendDeployCommand.run(args)
else
puts 'Usage: belt deploy frontend <environment>'
exit 1
end
},
%w[version --version -v] => ->(_args) { puts "Belt #{Belt::VERSION}" }
}.freeze
- COMMANDS =
COMMANDS_DEFINITION.each_with_object({}) do |(keys, handler), hash|
Array(keys).each { |key| hash[key] = handler }
end.freeze
- TERRAFORM_ACTIONS =
Belt::CLI::TerraformCommand::ACTIONS
Class Method Summary
collapse
Class Method Details
.start(args) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/belt/cli.rb', line 43
def self.start(args)
command = args.shift
if command.nil?
puts usage
exit 1
end
return Belt::CLI::TerraformCommand.run(command, args) if TERRAFORM_ACTIONS.include?(command)
handler = COMMANDS[command]
if handler.nil?
return Belt::CLI::TasksCommand.invoke(command, args) if Belt::CLI::TasksCommand.rake_task?(command)
puts "Unknown command: #{command}\n\n#{usage}"
exit 1
end
if handler.is_a?(Proc)
handler.call(args)
else
handler.run(args)
end
end
|
.usage ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/belt/cli.rb', line 71
def self.usage
<<~USAGE
Usage: belt <command> [options]
Commands:
new <app_name> [--frontend react] Create a new Belt application
generate <resource|model|controller> <name> Generate components
generate frontend <react|vue|svelte> Scaffold a frontend app
generate views <resource> [fields...] Generate React pages for REST actions
generate environment <name> Create a new environment
routes [-g PATTERN] [-f json] Show route definitions
tasks [-g PATTERN] [-a] List available rake tasks
-T [-g PATTERN] [-a] Alias for tasks
setup state Create/select S3 state bucket
setup tables <env> Generate DynamoDB tables from schema
setup frontend <env> Generate S3 + CloudFront infrastructure
deploy frontend <env> Build and deploy frontend to AWS
init <env> terraform init for environment
plan <env> terraform plan for environment
apply <env> terraform apply for environment
destroy <env> terraform destroy for environment
output <env> terraform output for environment
--version Show Belt version
Rake Tasks:
Any rake task from your Gemfile dependencies can be run directly:
belt lambda:build_layer Run a rake task by name
Environment:
Set BELT_ENV to skip the <env> argument:
export BELT_ENV=wups
belt apply # uses BELT_ENV
belt apply dev01 # explicit arg wins
Examples:
belt new blog --frontend react
belt generate resource post title:string content:text status:string
belt generate frontend react
belt setup frontend wups
belt deploy frontend wups
belt apply wups
belt tasks # list all rake tasks
belt lambda:build_layer # run a rake task directly
USAGE
end
|