Class: Certs::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/cert-help/command.rb

Overview

Provides terminal access to the ruby api

Deligates commands based on user input, displaying version, help, and listing certificates based on searches

Author:

Class Method Summary collapse

Class Method Details

.deligate(major, minor) ⇒ Object

Decides which command to execute based on major, minor



25
26
27
28
29
30
31
32
# File 'lib/cert-help/command.rb', line 25

def deligate(major, minor)
  return version if ['-v', '--version'].include?(major)

  return Certs::Apple.execute(minor) if major == 'apple'
  return Certs::Search.execute(minor) if major == 'search'

  help
end

.execute(*args) ⇒ Object

Terns ARGV to marjor, minor commands

Parameters:

  • *args (Array)

    The user input



15
16
17
18
19
20
21
22
# File 'lib/cert-help/command.rb', line 15

def execute(*args)

  major = args.shift
  minor = args.shift

  deligate(major, minor)

end

.helpObject

Informs the user how to use this program



35
36
37
38
39
40
41
# File 'lib/cert-help/command.rb', line 35

def help
  puts "#{Certs::COMMAND} <command>"
  puts "\t-h --help              prints this help screen"
  puts "\t-v --version           show the current version"
  puts "\tsearch <term>          search for a certificate"
  puts "\tapple <method>         find apple certificates"
end

.versionObject

Shows the user which version is being used



44
45
46
# File 'lib/cert-help/command.rb', line 44

def version
  puts "Version: #{Certs::VERSION}"
end