Class: NexClient::Cli
- Inherits:
-
Object
- Object
- NexClient::Cli
- Includes:
- Commander::Methods
- Defined in:
- lib/nex_client/cli.rb
Instance Method Summary collapse
-
#run ⇒ Object
include whatever modules you need.
Instance Method Details
#run ⇒ Object
include whatever modules you need
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 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 70 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 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 |
# File 'lib/nex_client/cli.rb', line 12 def run program :name, 'nex-cli' program :version, NexClient::VERSION program :description, 'Nex!™ PaaS Client' default_command :help command :addons do |c| c.syntax = 'nex-cli addons [APP_NAME] [options]' c.summary = 'Manage addons' c.description = 'List addons' c.example 'list all active addons', 'nex-cli addons' c.example 'list all active addons for myapp', 'nex-cli addons myapp' c.example 'list all including terminated addons', 'nex-cli addons --all' c.option '--all', 'list all addons (no filtering)' c.option '--status <active|terminated>', String, 'list all addons in a given status' c.option '--service <mysql|redis>', String, 'list all addons for a specific service' c.action do |args, | NexClient::Commands::Addons.list(args,) end end command :'addons:create' do |c| c.syntax = 'nex-cli addons:create SERVICE APP_NAME' c.summary = 'Create addons' c.description = 'Create addons for your apps' c.example 'create mysql addon for myapp', 'nex-cli addons:create mysql myapp' c.example 'create redis addon for myapp', 'nex-cli addons:create redis myapp' c.action do |args, | NexClient::Commands::Addons.create(args,) end end command :'addons:delete' do |c| c.syntax = 'nex-cli addons:delete ADDON_NAME' c.summary = 'Delete addons' c.description = 'Permanently delete an addons' c.example 'delete addon my-addon', 'nex-cli addons:delete my-addon' c.action do |args, | NexClient::Commands::Addons.destroy(args,) end end command :'addons:logs' do |c| c.syntax = 'nex-cli addons:logs APP_NAME [options]' c.summary = 'Gather addon logs' c.description = 'Gather container logs for a given addon' c.example 'gather logs for myaddon', 'nex-cli addons:logs myaddon' c.example 'gather logs for myapp with a tail of 50', 'nex-cli addons:logs --tail 50 myaddon' c.option '--tail NUMBER', String, 'number of lines to retrieve for each container' c.action do |args, | NexClient::Commands::Addons.logs(args,) end end command :apps do |c| c.syntax = 'nex-cli apps [options]' c.summary = 'Manage apps' c.description = 'List, create, manage, scale and delete apps' c.example 'list all my active apps', 'nex-cli apps' c.example 'list all active apps for owner myorg', 'nex-cli apps --owner myorg' c.example 'list all my terminated apps', 'nex-cli apps --status terminated' c.example 'list all terminated apps for owner myorg', 'nex-cli apps --status terminated --owner myorg' c.option '--all', 'list all apps (no filtering)' c.option '--status <active|terminated>', String, 'list all apps in a given status' c.option '--ssl', 'list all apps with SSL enabled' c.option '--storage', 'list all apps with persistent storage' c.option '--owner HANDLE', 'list all apps for the specified owner' c.action do |args, | NexClient::Commands::Apps.list(args,) end end command :'apps:create' do |c| c.syntax = 'nex-cli apps:create DOCKER_IMAGE[:tag] [options]' c.summary = 'Create apps' c.description = 'Create new docker applications' c.example 'create new rails application', 'nex-cli apps:create rails' c.option '--env MYVAR=value,MYVAR2=value,...', Array, 'comma separated list of env variables' c.option '--env-file FILE', 'newline separated list of env variables' c.option '--no-ssl', 'disable SSL support (enabled by default)' c.option '--storage', 'enable persistent storage (/!\ only one node allowed)' c.option '--owner ORGANIZATION_HANDLE', 'specify an organisation as owner (organization admin only)' c.action do |args, | NexClient::Commands::Apps.create(args,) end end command :'apps:delete' do |c| c.syntax = 'nex-cli apps:delete APP_NAME' c.summary = 'Delete an app' c.description = 'Permanently delete an app' c.example 'delete my-awesome-app', 'nex-cli apps:delete my-awesome-app' c.action do |args, | NexClient::Commands::Apps.destroy(args,) end end command :'apps:down' do |c| c.syntax = 'nex-cli apps:down APP_NAME [options]' c.summary = 'Scale applications down' c.description = 'Bring nodes down for a given application' c.example 'scale myapp down by removing one node', 'nex-cli apps:down myapp' c.example 'scale myapp down by removing two nodes', 'nex-cli apps:down myapp --count 2' c.option '--count NUMBER', String, 'number of nodes to bring down' c.action do |args, | NexClient::Commands::Apps.scale(:down,args,) end end command :'apps:info' do |c| c.syntax = 'nex-cli apps:info APP_NAME [options]' c.summary = 'Show information about an app' c.description = 'Show all details about an app' c.example 'show details about myapp', 'nex-cli apps:info myapp' c.action do |args, | NexClient::Commands::Apps.info(args,) end end command :'apps:logs' do |c| c.syntax = 'nex-cli apps:logs APP_NAME [options]' c.summary = 'Gather app logs' c.description = 'Gather container logs for a given app' c.example 'gather logs for myapp', 'nex-cli apps:logs myapp' c.example 'gather logs for myapp with a tail of 50', 'nex-cli apps:logs --tail 50 myapp' c.option '--tail NUMBER', String, 'number of lines to retrieve for each container' c.action do |args, | NexClient::Commands::Apps.logs(args,) end end command :'apps:restart' do |c| c.syntax = 'nex-cli apps:restart APP_NAME' c.summary = 'Restart an app' c.description = 'Initiate a phased restart of an app' c.example 'phase-restart my-awesome-app', 'nex-cli apps:restart my-awesome-app' c.action do |args, | NexClient::Commands::Apps.restart(args,) end end command :'apps:scm' do |c| c.syntax = 'nex-cli apps:scm APP_NAME [options]' c.summary = 'Manage the SCM of your apps' c.description = 'Link/unlink an SCM (e.g. github) to your applications' c.example 'link myapp to github using some/repo on branch master', 'nex-cli apps:scm myapp --link github:some/repo' c.example 'link myapp to github using some/repo on branch develop', 'nex-cli apps:scm myapp --link github:some/repo:develop' c.option '--link <provider>:<repo>[:branch]', String, 'link your SCM repo to this application (only github supported)' c.option '--unlink', 'unlink your SCM from the application' c.action do |args, | NexClient::Commands::Apps.manage_scm(args,) end end command :'apps:up' do |c| c.syntax = 'nex-cli apps:up APP_NAME [options]' c.summary = 'Scale applications up' c.description = 'Add nodes to a given application' c.example 'scale myapp up by adding one node', 'nex-cli apps:up myapp' c.example 'scale myapp up by adding two nodes', 'nex-cli apps:up myapp --count 2' c.option '--count NUMBER', String, 'number of nodes to bring up' c.action do |args, | NexClient::Commands::Apps.scale(:up,args,) end end command :'apps:vars' do |c| c.syntax = 'nex-cli apps:vars APP_NAME [options]' c.summary = 'Manage app environment variables' c.description = 'List and update environment variables for an app' c.example 'list all env variables for myapp', 'nex-cli apps:vars myapp' c.example 'Add env variables to myapp', 'nex-cli apps:vars myapp --add MYVAR1=VAL1,MYVAR2=VAL2' c.example 'Delete env variables from myapp', 'nex-cli apps:vars myapp --delete MYVAR,MYVAR' c.option '--add MYVAR=value,MYVAR2=value,...', Array, 'comma separated list of env variables' c.option '--delete MYVAR,MYVAR2,...', Array, 'comma separated list of env variables' c.action do |args, | NexClient::Commands::Apps.manage_vars(args,) end end command :cubes do |c| c.syntax = 'nex-cli cubes [options]' c.summary = 'Manage cubes [platform admin]' c.description = 'List, create, manage, scale and delete cubes' c.example 'list all running cubes', 'nex-cli cubes' c.example 'list all running cubes for owner myorg', 'nex-cli cubes --owner myorg' c.example 'list all terminated cubes', 'nex-cli cubes --status terminated' c.example 'list all terminated cubes for owner myorg', 'nex-cli cubes --status terminated --owner myorg' c.example 'list cube xyz.domain.co', 'nex-cli cubes --name xyz.domain.co' c.example 'list cube xyz', 'nex-cli cubes --name xyz' c.option '--all', 'list all cubes (no filtering)' c.option '--status <provisioning|running|stopped|terminated>', String, 'list all cubes in a given status' c.option '--ssl', 'list all cubes with SSL enabled' c.option '--storage', 'list all cubes with persistent storage' c.option '--soa', 'list all apps with soa enabled [legacy]' c.option '--dns DNS_NAME', 'list cube by dns (xyz.domain.com) or root dns (xyz)' c.option '--app APP_NAME', 'list all cubes attached to the specified app' c.option '--addon ADDON_NAME', 'list all cubes attached to the specified addon' c.option '--owner HANDLE', 'list all cubes for the specified owner' c.action do |args, | NexClient::Commands::CubeInstances.list(args,) end end command :'cubes:restart' do |c| c.syntax = 'nex-cli cubes:restart CUBE_NAME' c.summary = 'Restart a cube' c.description = 'Restart a cube' c.example 'restart cube xyz', 'nex-cli cubes:restart xyz' c.action do |args, | NexClient::Commands::CubeInstances.trigger_action(:restart,args,) end end command :'cubes:start' do |c| c.syntax = 'nex-cli cubes:start CUBE_NAME' c.summary = 'Start a cube' c.description = 'Start a cube' c.example 'start cube xyz', 'nex-cli cubes:start xyz' c.action do |args, | NexClient::Commands::CubeInstances.trigger_action(:start,args,) end end command :'cubes:stop' do |c| c.syntax = 'nex-cli cubes:stop CUBE_NAME' c.summary = 'Stop a cube' c.description = 'Stop a cube' c.example 'stop cube xyz', 'nex-cli cubes:stop xyz' c.action do |args, | NexClient::Commands::CubeInstances.trigger_action(:stop,args,) end end command :cube_templates do |c| c.syntax = 'nex-cli cube_templates [options]' c.summary = 'Manage cube_templates [platform admin][legacy]' c.description = 'List, create, manage, scale and delete cube templates' c.example 'list all templates', 'nex-cli cube_templates' c.example 'list all docker templates', 'nex-cli cube_templates --stack docker' c.example 'list specific template', 'nex-cli cube_templates --name mytemplate' c.example 'list templates using image someimage', 'nex-cli cube_templates --image someimage' c.option '--stack <lxc|docker>', 'list all templates for the specified stack' c.option '--name TEMPLATE_NAME', 'list specific template' c.option '--image IMAGE_NAME', 'list templates using a specific image' c.action do |args, | NexClient::Commands::CubeTemplates.list(args,) end end command :domains do |c| c.syntax = 'nex-cli domains [APP_NAME] [options]' c.summary = 'Manage domains' c.description = 'List domains' c.example 'list all domains', 'nex-cli addons' c.example 'list all domains matching example.com', 'nex-cli domains --domain example.com' c.option '--domain', 'list all domains matching the provided cname' c.action do |args, | NexClient::Commands::Domains.list(args,) end end command :'domains:create' do |c| c.syntax = 'nex-cli domains:create CNAME APP_NAME' c.summary = 'Create domains' c.description = 'Create domains for your apps' c.example 'create some.example.com cname for myapp', 'nex-cli domains:create some.example.com myapp' c.action do |args, | NexClient::Commands::Domains.create(args,) end end command :'domains:delete' do |c| c.syntax = 'nex-cli domains:delete CNAME' c.summary = 'Delete domains' c.description = 'Permanently delete a domain' c.example 'delete domain some.example.com', 'nex-cli domains:delete some.example.com' c.action do |args, | NexClient::Commands::Domains.destroy(args,) end end command :organizations do |c| c.syntax = 'nex-cli organizations [options]' c.summary = 'List organizations' c.description = 'List organizations' c.example 'list all organizations', 'nex-cli organizations' c.action do |args, | NexClient::Commands::Organizations.list(args,) end end command :racks do |c| c.syntax = 'nex-cli racks [options]' c.summary = 'Manage racks [platform admin]' c.description = 'List, create, manage, delete racks' c.example 'list all running racks', 'nex-cli racks' c.example 'list all running racks', 'nex-cli racks --status running' c.example 'list all stopped racks', 'nex-cli racks --status stopped' c.example 'list all terminated racks', 'nex-cli racks --status terminated' c.example 'list all racks', 'nex-cli racks --all' c.option '--all', 'list all racks (no filtering)' c.option '--status <provisioning|running|stopped|terminated>', String, 'list all racks in a given status' c.option '--type <compute|storage|routing|gateway>', String, 'list all racks of the specified type' c.option '--stack <lxc|docker>', String, 'list all compute racks for the specified stack' c.action do |args, | NexClient::Commands::Racks.list(args,) end end command :certs do |c| c.syntax = 'nex-cli certs [APP_NAME] [options]' c.summary = 'Manage certs' c.description = 'List ssl certificates' c.example 'list all certs', 'nex-cli certs' c.example 'list all certs matching example.com', 'nex-cli certs --domain example.com' c.option '--domain', 'list all certs matching the provided cname' c.action do |args, | NexClient::Commands::SslCertificates.list(args,) end end command :'certs:create' do |c| c.syntax = 'nex-cli certs:create CNAME APP_NAME' c.summary = 'Create ssl certificates' c.description = 'Create certs for your apps' c.example 'create some.example.com certificate for myapp', 'nex-cli certs:create some.example.com myapp' c.option '--cert CERT_PATH', String, 'path to pem certificate' c.option '--bundle BUNDLE_PATH', String, 'path to certificate bundle' c.option '--privkey KEY_PATH', String, 'path to certificate private key' c.action do |args, | NexClient::Commands::SslCertificates.create(args,) end end command :'certs:delete' do |c| c.syntax = 'nex-cli certs:delete CNAME' c.summary = 'Delete certs' c.description = 'Permanently delete a ssl certificate' c.example 'delete certificate for some.example.com', 'nex-cli certs:delete some.example.com' c.action do |args, | NexClient::Commands::SslCertificates.destroy(args,) end end command :users do |c| c.syntax = 'nex-cli users [options]' c.summary = 'List users' c.description = 'List users' c.example 'list all users', 'nex-cli users' c.example 'list all users in doecorp organization', 'nex-cli users --organization doecorp' c.example 'list all api-only users in doecorp organization', 'nex-cli users --api --organization doecorp' c.option '--org ORG_HANDLE', String, 'list all users in the specified organization' c.option '--organization ORG_HANDLE', String, 'list all users in the specified organization' c.option '--api', 'list api-only users' c.action do |args, | NexClient::Commands::Users.list(args,) end end command :'users:create' do |c| c.syntax = 'nex-cli users:create [options]' c.summary = 'Create API users' c.description = 'Create API users for organizations' c.example 'create api user for doecorp organization', 'nex-cli users:create doecorp' c.action do |args, | NexClient::Commands::Users.create_api_user(args,) end end command :'users:delete' do |c| c.syntax = 'nex-cli users:delete HANDLE [options]' c.summary = 'Delete API users' c.description = 'Delete API users from organizations' c.example 'delete api user doecorp/37fhsg', 'nex-cli users:delete doecorp/37fhsg' c.action do |args, | NexClient::Commands::Users.destroy(args,) end end run! end |