Skip to content

Commit

Permalink
Merge pull request #4 from y2k2mt/search-resources
Browse files Browse the repository at this point in the history
Search resources by URL
  • Loading branch information
y2k2mt authored Oct 20, 2022
2 parents bef243b + 946887c commit 7277fd3
Showing 1 changed file with 37 additions and 31 deletions.
68 changes: 37 additions & 31 deletions src/cli.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,52 @@ mode = Config::Mode::Replay
base_url : String? = nil
query_options : Array(String) = [] of String

parsed = OptionParser.parse do |parser|
parser.banner = "Replay: Record and Preplay!"
begin
parsed = OptionParser.parse do |parser|
parser.banner = "Replay: Record and Preplay!"

parser.on "-v", "--version", "Show version" do
puts Replay::VERSION
exit
end
parser.on "-v", "--version", "Show version" do
puts Replay::VERSION
exit
end

parser.on "-h", "--help", "Show help" do
puts parser
exit
end
parser.on "-h", "--help", "Show help" do
puts parser
exit
end

parser.on "-p PORT", "--port PORT", "Server port" do |port|
port.to_i16?.try do |port_number|
server_port = port_number
parser.on "-p PORT", "--port PORT", "Server port" do |port|
port.to_i16?.try do |port_number|
server_port = port_number
end
end
end

parser.on "-r URL", "--record URL", "Run as recording mode" do |url|
mode = Config::Mode::Record
base_url = url
end
parser.on "-r URL", "--record URL", "Run as recording mode" do |url|
mode = Config::Mode::Record
base_url = url
end

parser.on "-R URL", "--replay URL", "Run as replaying mode" do |url|
mode = Config::Mode::Replay
base_url = url
end
parser.on "-R URL", "--replay URL", "Run as replaying mode" do |url|
mode = Config::Mode::Replay
base_url = url
end

parser.on "-f URL", "--find URL", "Find resources" do |_|
query_options = ARGV[1..]
base_url = query_options[0]
mode = Config::Mode::Replay
end
parser.on "-f URL", "--find URL", "Find resources" do |_|
query_options = ARGV[1..]
base_url = query_options[0]
mode = Config::Mode::Replay
end

parser.invalid_option do |flag|
STDERR.puts "ERROR: #{flag} is not a valid option."
STDERR.puts parser
exit(1)
parser.invalid_option do |flag|
STDERR.puts "ERROR: #{flag} is not a valid option."
STDERR.puts parser
exit(1)
end
end
rescue ex
puts ex
STDERR.puts parsed
exit(1)
end

if !base_url
Expand Down

0 comments on commit 7277fd3

Please sign in to comment.