Module: Ronin::Core::CLI::Printing::Params
- Includes:
- CommandKit::Printing::Tables
- Defined in:
- lib/ronin/core/cli/printing/params.rb
Overview
Handles printing params defined on a class.
Constant Summary collapse
- PARAM_TABLE_HEADER =
The params table header.
%w[Name Type Required Default Description]
Instance Method Summary collapse
-
#print_params(klass) ⇒ Object
Prints the params defined in the given class.
Instance Method Details
#print_params(klass) ⇒ Object
Prints the params defined in the given class.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/ronin/core/cli/printing/params.rb', line 42 def print_params(klass) return if klass.params.empty? rows = [] klass.params.each do |name,param| param_type = param.type.class.name.split('::').last required = if param.required? then 'Yes' else 'No' end default = param.default_value description = param.desc rows << [name, param_type, required, default, description] end puts "Params:" puts indent do print_table(rows,header: PARAM_TABLE_HEADER, border: :line) end end |