instance method
SyntaxSuggest::Cli#call
call
lib/syntax_suggest/cli.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/lib/syntax_suggest/cli.rb, line 32
def call
if @argv.empty?
# Display help if raw command
parser.parse! %w[--help]
return
else
# Mutates @argv
parse
return if options[:exit]
end
file_name = @argv.first
if file_name.nil?
@io.puts "No file given"
@exit_obj.exit(1)
return
end
file = Pathname(file_name)
if !file.exist?
@io.puts "file not found: #{file.expand_path} "
@exit_obj.exit(1)
return
end
@io.puts "Record dir: #{options[:record_dir]}" if options[:record_dir]
display = SyntaxSuggest.call(
io: @io,
source: file.read,
filename: file.expand_path,
terminal: options.fetch(:terminal, SyntaxSuggest::DEFAULT_VALUE),
record_dir: options[:record_dir]
)
if display.document_ok?
@io.puts "Syntax OK"
@exit_obj.exit(0)
else
@exit_obj.exit(1)
end
end
No documentation available