Class: DRep::DRepCli
- Includes:
- DRepRunnable
- Defined in:
- lib/drep/drep_cli.rb
Constant Summary collapse
- DREP_EXEC_OPTIONS =
{:provider_flag => ['-p', '--provider PROVIDER[;SOURCE_1[,SOURCE_2]][;RULE_1[,RULE_2]][;OPTIONS]', 'Provider path with sources and rules specifications.'], :template_flag => ['-t', '--template PATH[>OUTPUT_PATH]', 'Template in/out path. By default output will be flushed to "STDOUT"'], :version_flag => ['-v', '--version', 'Display version information and exit.'], :help_flag => ['-h', '--help', 'Display this help message and exit.'], :quiet_flag => ['-q', '--quiet', 'Start in quiet mode without any CLI messages.'], :verbose_flag => ['-V', '--verbose', 'Start in verbose mode (ignored in quiet mode).'], :debug_flag => ['-d', '--debug', 'Start in debug mode.']}
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Instance Method Summary collapse
-
#initialize(stdin = STDIN, stdout = STDOUT, stderr = STDERR, arguments = []) ⇒ DRepCli
constructor
A new instance of DRepCli.
- #run ⇒ Object
Constructor Details
#initialize(stdin = STDIN, stdout = STDOUT, stderr = STDERR, arguments = []) ⇒ DRepCli
Returns a new instance of DRepCli.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/drep/drep_cli.rb', line 62 def initialize(stdin = STDIN, stdout = STDOUT, stderr = STDERR, arguments = []) @options = OpenStruct.new() begin = [stdin, stdout, stderr, @options] @env = DRepEnvironment.new(*) rescue Exception => e unless @stderr.nil? @stderr.puts("#{UNIX_NAME}: initialization failed: #{e.}") end exit(1) end @options.arguments = arguments.nil? ? [] : arguments @options.verbose = false @options.quiet = false @options.debug = false @options.output = @stdout @options.show_version = false @options.show_help = false @options.providers = [] @options.templates = [] @parser = OptionParser.new() end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
56 57 58 |
# File 'lib/drep/drep_cli.rb', line 56 def env @env end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
58 59 60 |
# File 'lib/drep/drep_cli.rb', line 58 def @options end |
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
60 61 62 |
# File 'lib/drep/drep_cli.rb', line 60 def parser @parser end |
Instance Method Details
#run ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/drep/drep_cli.rb', line 94 def run() if () begin if @options.verbose = "#{FULL_NAME} has started" msg("#{}: #{DateTime.now}.") end perform_tasks() if @options.verbose = "#{FULL_NAME} has finished all tasks" msg("#{}: #{DateTime.now}.") end rescue Exception => e err("Execution failed: #{e.}") end end end |