Skip to content

Commit

Permalink
Added small debug logging for exclude regex
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiDreyer committed Nov 8, 2024
1 parent 548a7ac commit 21bc29b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions exe/ruby_ast_gen
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ options = {
input: nil,
output: '.ast',
exclude: '^(tests?|vendor|spec)',
debug: false
}

# Parse ARGV manually
Expand All @@ -26,6 +27,9 @@ while i < ARGV.size
when '-e', '--exclude'
i += 1
options[:exclude] = ARGV[i]
when '-d', '--debug'
i += 1
options[:debug] = true
when '--version'
puts RubyAstGen::VERSION
exit
Expand All @@ -35,6 +39,7 @@ Usage:
-i, --input The input file or directory (required)
-o, --output The output directory (default: '.ast')
-e, --exclude The exclusion regex (default: '^(tests?|vendor|spec)')
-d, --debug Enable debug logging
--version Print the version
--help Print usage
HELP
Expand Down
12 changes: 12 additions & 0 deletions lib/ruby_ast_gen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ module RubyAstGen

module Logger

def self.debug(message)
puts "[DEBUG] #{message}"
end

def self.info(message)
puts "[INFO] #{message}"
end
Expand All @@ -25,10 +29,18 @@ def self.error(message)

# Main method to parse the input and generate the AST output
def self.parse(opts)
if opts[:debug]
RubyAstGen::Logger::debug "CLI Arguments received: #{opts}"
end

input_path = opts[:input]
output_dir = opts[:output]
exclude_regex = Regexp.new(opts[:exclude])

if opts[:debug]
RubyAstGen::Logger::debug "Exclude Regex Received: #{exclude_regex}"
end

FileUtils.mkdir_p(output_dir)

if File.file?(input_path)
Expand Down

0 comments on commit 21bc29b

Please sign in to comment.