Class: TlaParserS::Cli

Inherits:
Thor
  • Object
show all
Includes:
Utils::MyLogger
Defined in:
lib/cli/cli.rb

Constant Summary collapse

PROGNAME =

logger progname

"main"
VERSION_BANNER =
<<-EOS
#{File.basename $0} - #{TlaParserS::version}   
EOS

Constants included from Utils::MyLogger

Utils::MyLogger::LOGFILE

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils::MyLogger

#getLogger, #logfile

Constructor Details

#initialize(*args) ⇒ Cli


constructore



39
40
41
42
43
# File 'lib/cli/cli.rb', line 39

def initialize(*args)
  super
  @logger = getLogger( PROGNAME, options )
  @logger.info( "#{__method__} initialized" )
end

Class Method Details

.add_shared_option(name, options = {}) ⇒ Object



21
22
23
24
# File 'lib/cli/cli.rb', line 21

def add_shared_option(name, options = {})
  @shared_options = {} if @shared_options.nil?
  @shared_options[name] =  options
end

.shared_options(*option_names) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/cli/cli.rb', line 26

def shared_options(*option_names)
  option_names.each do |option_name|
    opt =  @shared_options[option_name]
    raise "Tried to access shared option '#{option_name}' but it was not previously defined" if opt.nil?
    yield option_name, opt if block_given?
    option option_name, opt
  end
end

Instance Method Details

#resolve(*entrypoints) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
# File 'lib/cli/cli.rb', line 75

def resolve( *entrypoints )
  entries = []
  # iterate globs and choose dirtory entries
  options[:dir_globs].each { |glob|  entries += Dir.glob( glob ).select { |path| File.file?(path ) }  }
  @logger.info( "#{__method__} entries=#{entries}" )
  result = TlaParserS::Resolver.new( options ).
    initSnippets( entries.map { |fileName| File.new(fileName )}  ).
    resolveModules( entrypoints )
  @logger.info( "#{__method__} result=#{result}" )      
  puts result
end

#versionObject



60
61
62
# File 'lib/cli/cli.rb', line 60

def version()
  puts VERSION_BANNER
end