Class: Polites::Cli
- Inherits:
-
Object
- Object
- Polites::Cli
- Defined in:
- lib/polites/cli.rb
Overview
Provides the implentation of the command-line interface, exposing functions to be called from a shell or other programs.
Instance Method Summary collapse
-
#call(args) ⇒ nil
Invoke the program with some options.
-
#initialize(stdin:, stdout:, options: {}) ⇒ Cli
constructor
A new instance of Cli.
Constructor Details
#initialize(stdin:, stdout:, options: {}) ⇒ Cli
Returns a new instance of Cli.
17 18 19 20 21 |
# File 'lib/polites/cli.rb', line 17 def initialize(stdin:, stdout:, options: {}) @stdin = stdin @stdout = stdout @options = end |
Instance Method Details
#call(args) ⇒ nil
Invoke the program with some options.
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/polites/cli.rb', line 27 def call(args) filenames = option_parser.parse(args, into: @options) if @options[:help] @stdout.puts option_parser elsif @options[:version] @stdout.puts Polites::VERSION elsif filenames.any? filenames.each do |filename| @stdout.puts Convert.new.call(filename) end end nil end |