Class: Brick::CLI_Validator
- Inherits:
-
Object
- Object
- Brick::CLI_Validator
- Defined in:
- lib/brick/cli__validator.rb
Constant Summary collapse
- NO_COMMAND_GIVEN =
"You need to pass a sub-command (e.g., brick SUB-COMMAND)\n"
Class Method Summary collapse
- .no_command_given? ⇒ Boolean
- .no_subcommand_given? ⇒ Boolean
- .print_help_and_exit(exitcode = 1, fatal_message = nil) ⇒ Object
- .validate ⇒ Object
Class Method Details
.no_command_given? ⇒ Boolean
16 17 18 |
# File 'lib/brick/cli__validator.rb', line 16 def self.no_command_given? ARGV.empty? end |
.no_subcommand_given? ⇒ Boolean
12 13 14 |
# File 'lib/brick/cli__validator.rb', line 12 def self.no_subcommand_given? ARGV[0] =~ /^-/ end |
.print_help_and_exit(exitcode = 1, fatal_message = nil) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/brick/cli__validator.rb', line 20 def self.print_help_and_exit(exitcode=1, =nil) Brick::CLI::logger.error() if Brick::CLI.list_parameters Brick::CLI.list_commands exit exitcode end |
.validate ⇒ Object
5 6 7 8 9 10 |
# File 'lib/brick/cli__validator.rb', line 5 def self.validate if no_command_given? print_help_and_exit(1, NO_COMMAND_GIVEN) end end |