class GitLab::CI::Lint::Arguments

Attributes

program_name[R]

Public Class Methods

new() click to toggle source
# File lib/gitlab/ci/lint/arguments.rb, line 11
def initialize
  @program_name = File.basename(__FILE__).colorize(:yellow)
  @program_version = Gitlab::Ci::Lint::VERSION.colorize(:yellow)
  @options = {
    verbose: false
  }
end

Public Instance Methods

command_line_parser() click to toggle source
# File lib/gitlab/ci/lint/arguments.rb, line 19
def command_line_parser
  OptionParser.new do |opts|
    opts.banner = "Usage: example.rb [options]"
    opts.on("-h", "--helper", "Show helper documentation") { |value| @options[:help] = helper() }
    opts.on("-e", "--endpoint", "GitLab Endpoint") { |value| @options[:endpoint] = value }
    opts.on("-t", "--token", "GitLab Token") { |value| @options[:token] = value }
    opts.on("-f", "--file", "GitLab CI File") { |value| @options[:file] = value }
    opts.on("-d", "--directory", "GitLab CI Directory") { |value| @options[:directory] = value }
    opts.on("-T", "--timeout", "Request Timeout") { |value| @options[:timeout] = value }
    opts.on("-n", "--no-color", "Color Usage") { |value| @options[:nocolor] = value }
    opts.on("-v", "--values", "Values File") { |value| @options[:values] = value }
    opts.on("-l", "--log", "Log File") { |value| @options[:log] = value }
    opts.on("--verbose", "If set, print verbose output") { |value| @options[:verbose] = true }
    opts.on("--version", "Show GitLab CI Lint Version") { |value| @options[:version] = version() }
  end.parse!
  return @options
end

Private Instance Methods

helper() click to toggle source
# File lib/gitlab/ci/lint/arguments.rb, line 39
def helper
  string = """

Command Line Helper to the Program - #{@program_name}
Usage Exemple: ruby example.rb [global options] [command [command options]] [PATH]

Global options:
-h          | --helper                show GitLab CI help.
-e          | --endpoint              root URL of the GitLab instance to use API (default: 'https://gitlab.com')
-t          | --token                 GitLab Token value used to private hosts.
-f          | --file                  FILE is the relative or absolute path to the gitlab-ci file
-d          | --directory             DIR is the directory from where to search for gitlab-ci file and git repository (default: '.')
-T          | --timeout               timeout in second after which http request to GitLab API will timeout (and the program will fails) (default: 5)
-n          | --no-color              don't color output. By defaults the output is colorized if a compatible terminal is detected.
-v          | --values                Values file with information.
-l          | --log                   LOG is the log file path.
-v          | --verbose               verbose mode.
-V          | --version               print the version information.
"""
  puts string
  exit 1
end
version() click to toggle source
# File lib/gitlab/ci/lint/arguments.rb, line 62
def version
  string = """

  GitLab CI Lint Version: #{@program_version}
  """
  puts string
  exit
end