Skip to content

Commit

Permalink
Merge pull request #441 from owasp-noir:improve-banner
Browse files Browse the repository at this point in the history
Refactor config initializer and options parser
  • Loading branch information
hahwul authored Nov 1, 2024
2 parents 67ec0f2 + 90a50ed commit 439a861
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
7 changes: 1 addition & 6 deletions src/config_initializer.cr
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ class ConfigInitializer

# Create the config file if it doesn't exist
File.write(@config_file, generate_config_file) unless File.exists?(@config_file)
rescue e : Exception
puts "Failed to create config directory or file: #{e.message}"
puts "Using default config."
rescue
end

def read_config
Expand Down Expand Up @@ -71,9 +69,6 @@ class ConfigInitializer
final_options = default_options.merge(symbolized_hash) { |_, _, new_val| new_val }
final_options
rescue e : Exception
puts "Failed to read config file: #{e.message}"
puts "Using default config."

default_options
end
end
Expand Down
4 changes: 1 addition & 3 deletions src/noir.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ module Noir
VERSION = "0.18.0"
end

# Print banner
banner()

# Run options parser
noir_options = run_options_parser()

Expand Down Expand Up @@ -57,6 +54,7 @@ if noir_options["exclude_codes"] != ""
end

# Run Noir
banner()
app = NoirRunner.new noir_options
start_time = Time.monotonic

Expand Down
4 changes: 1 addition & 3 deletions src/options.cr
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,10 @@ def run_options_parser
case var
when "zsh"
puts generate_zsh_completion_script
STDERR.puts "\n> Instructions: Copy the content above and save it in the zsh-completion directory as _noir".colorize(:yellow)
when "bash"
puts generate_bash_completion_script
STDERR.puts "\n> Instructions: Copy the content above and save it in the .bashrc file as noir.".colorize(:yellow)
when "fish"
puts generate_fish_completion_script
STDERR.puts "\n> Instructions: Copy the content above and save it in the fish-completion directory as noir.fish".colorize(:yellow)
else
puts "ERROR: Invalid completion type.".colorize(:yellow)
puts "e.g., noir --generate-completion zsh"
Expand All @@ -164,6 +161,7 @@ def run_options_parser
end
parser.separator "\n OTHERS:".colorize(:blue)
parser.on "-h", "--help", "Show help" do
banner()
puts parser
puts ""
puts "EXAMPLES:"
Expand Down

0 comments on commit 439a861

Please sign in to comment.