Class: Rubycc::Pkgconf::Cli
- Inherits:
-
Object
- Object
- Rubycc::Pkgconf::Cli
- Defined in:
- lib/rubycc/pkgconf/cli.rb
Overview
Parses argv into requested options + module names and renders exactly
the options given, in the order given, onto one line — mirroring how
mkmf's pkg_config() invokes $PKGCONFIG with all of a single call's
--#{option} flags at once and reads back one combined line of output.
Instance Method Summary collapse
-
#initialize(argv, stdout:, stderr:, resolver:, filter:) ⇒ Cli
constructor
A new instance of Cli.
- #run ⇒ Object
Constructor Details
#initialize(argv, stdout:, stderr:, resolver:, filter:) ⇒ Cli
Returns a new instance of Cli.
30 31 32 33 34 35 36 37 38 |
# File 'lib/rubycc/pkgconf/cli.rb', line 30 def initialize(argv, stdout:, stderr:, resolver:, filter:) @argv = argv @out = stdout @err = stderr @resolver = resolver @filter = filter @options = [] @modules = [] end |
Instance Method Details
#run ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rubycc/pkgconf/cli.rb', line 40 def run parse_argv return 1 if @options.empty? if @modules.empty? @err.puts "#{PROG}: no package name specified" return 1 end if @options.include?("exists") @modules.all? { |name| @resolver.exists?(name) } ? 0 : 1 else render end rescue PkgconfError => e @err.puts "#{PROG}: #{e.}" 1 end |