Module: Travis::CLI

Extended by:
CLI
Included in:
CLI
Defined in:
lib/travis/cli.rb,
lib/travis/cli/raw.rb,
lib/travis/cli/help.rb,
lib/travis/cli/login.rb,
lib/travis/cli/parser.rb,
lib/travis/cli/whoami.rb,
lib/travis/cli/command.rb,
lib/travis/cli/encrypt.rb,
lib/travis/cli/version.rb,
lib/travis/cli/endpoint.rb,
lib/travis/cli/api_command.rb,
lib/travis/cli/repo_command.rb

Defined Under Namespace

Modules: Parser Classes: ApiCommand, Command, Encrypt, Endpoint, Help, Login, Raw, RepoCommand, Version, Whoami

Instance Method Summary collapse

Instance Method Details

#command(name) ⇒ Object



43
44
45
46
47
48
49
50
51
52
# File 'lib/travis/cli.rb', line 43

def command(name)
  const_name = command_name(name)
  constant   = CLI.const_get(const_name) if const_name =~ /^[A-Z][a-z]+$/ and const_defined? const_name
  if command? constant
    constant
  else
    $stderr.puts "unknown command #{name}"
    exit 1
  end
end

#commandsObject



54
55
56
# File 'lib/travis/cli.rb', line 54

def commands
  CLI.constants.map { |n| CLI.const_get(n) }.select { |c| command? c }
end

#run(*args) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/travis/cli.rb', line 35

def run(*args)
  args, opts = preparse(args)
  name       = args.shift unless args.empty?
  command    = command(name).new(opts)
  command.parse(args)
  command.execute
end

#windows?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/travis/cli.rb', line 31

def windows?
  RUBY_PLATFORM =~ /mswin|mingw/
end