Method: QB::Role#usage

Defined in:
lib/qb/role.rb

#usageString

Returns usage information formatted as plain text for the CLI.

Returns:

  • (String)

    usage information formatted as plain text for the CLI.



379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'lib/qb/role.rb', line 379

def usage
  # Split up options by required and optional.
  required_options = []
  optional_options = []
  
  options.each { |option|
    if option.required?
      required_options << option
    else
      optional_options << option
    end
  }
  
  parts = ['qb [run]', name]
  
  required_options.each { |option|
    parts << option.usage
  }
  
  unless optional_options.empty?
    parts << '[OPTIONS]'
  end
  
  if has_dir_arg?
    parts << 'DIRECTORY'
  end
  
  parts.join ' '
end