# example

Optional

Defines an example command. This is purely decorative for the --help text and can be called multiple times.

title  'Admin Tools'

usage  'deploy [--build --env ENV]'
option '--build, -b', 'Build before deploying'
option '--env, -e ENV', 'Specify environment to deploy to [default: stage]'

example 'deploy --env production'
example 'deploy -b -e stage'

action 'deploy' do |args|
  env = args['--env']
  say 'Building...' if args['--build']
  say "Deploying to #{env}"
end
$ run --help
Admin Tools

Usage:
  run deploy [--build --env ENV]
  run (--help | -h)

Options:
  --build, -b
    Build before deploying

  --env, -e ENV
    Specify environment to deploy to [default: stage]

  --help, -h
    Show this message

Examples:
  deploy --env production
  deploy -b -e stage

If you require more flexibility in the example output, you can use a multi-line string. Indentation and word wrapping will be taken care of automatically.

title  'Admin Tools'

usage  'deploy [--build --env ENV]'
option '--build, -b', 'Build before deploying'
option '--env, -e ENV', 'Specify environment to deploy to [default: stage]'

example <<~EXAMPLE
  nb`Deploy to production`
  $ deploy --env production

  nb`Build and then deploy to stage`
  $ deploy -b -e stage
EXAMPLE

action 'deploy' do |args|
  env = args['--env']
  say 'Building...' if args['--build']
  say "Deploying to #{env}"
end
$ run --help
Admin Tools

Usage:
  run deploy [--build --env ENV]
  run (--help | -h)

Options:
  --build, -b
    Build before deploying

  --env, -e ENV
    Specify environment to deploy to [default: stage]

  --help, -h
    Show this message

Examples:
  Deploy to production
  $ deploy --env production

  Build and then deploy to stage
  $ deploy -b -e stage