Class: Elzar::Cli::Runner
- Inherits:
-
Object
- Object
- Elzar::Cli::Runner
show all
- Defined in:
- lib/elzar/cli.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.required_argument(*arg_names) ⇒ Object
20
21
22
23
|
# File 'lib/elzar/cli.rb', line 20
def self.required_argument(*arg_names)
@required_arguments ||= []
@required_arguments += arg_names
end
|
.required_arguments ⇒ Object
25
26
27
|
# File 'lib/elzar/cli.rb', line 25
def self.required_arguments
@required_arguments || []
end
|
.run(*args) ⇒ Object
14
15
16
17
18
|
# File 'lib/elzar/cli.rb', line 14
def self.run(*args)
runner = new(*args)
runner.require_arguments!
runner.run
end
|
Instance Method Details
#require_arguments! ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'lib/elzar/cli.rb', line 29
def require_arguments!
missing_arguments = self.class.required_arguments.select do |arg|
arg_value = self.instance_variable_get(:"@#{arg}")
arg_value.to_s.strip.empty?
end
raise MissingArgumentsError.new(cmd, missing_arguments) unless missing_arguments.empty?
end
|