Class: ICSP::Services::OptionParserService

Inherits:
Object
  • Object
show all
Defined in:
lib/csp_option_parser.rb

Overview

OptionParserService

Constant Summary collapse

APP_HELP =
<<~HELP
  Available commands are:
     certificate      Manage certificates
     container        Manage containers
     hardware         Manage hardware
     license          Manage license
     -----
     sign_file
     verify_signature
     encrypt_file
     decrypt_file

  See 'icsp COMMAND --help' for more information on a specific command.
  For full documentation, see: https://github.com/denblackstache/cryptopro-cli#readme
HELP

Instance Method Summary collapse

Instance Method Details

#parseObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/csp_option_parser.rb', line 23

def parse
  command = parse_command
  unless command
    puts 'No command passed'
    exit
  end

  subcommand_result = parse_subcommand(command)
  OpenStruct.new(
    command: command,
    subcommand: subcommand_result[:subcommand],
    arguments: subcommand_result[:arguments],
    options: subcommand_result[:options]
  )
end