Skip to content

Commit

Permalink
Merge pull request #6 from y2k2mt/feature/base-dir-for-record
Browse files Browse the repository at this point in the history
Add option for base directory of records and indexes
  • Loading branch information
y2k2mt authored Nov 24, 2022
2 parents 4f412f9 + 121f9e9 commit 58ce7ef
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/cli.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ server_port = 8899_i16
mode = Config::Mode::Replay
base_url : String? = nil
query_options : Array(String) = [] of String
base_dir : String? = nil

begin
parsed = OptionParser.parse do |parser|
Expand All @@ -25,6 +26,12 @@ begin
end
end

parser.on "-d DIR", "--dir DIR", "Base directory for records and indexes" do |dir|
dir.try do |d|
base_dir = d
end
end

parser.on "-r URL", "--record URL", "Run as recording mode" do |url|
mode = Config::Mode::Record
base_url = url
Expand Down Expand Up @@ -61,7 +68,11 @@ end

base_url.try do |url|
if (query_options.empty?)
start_server(Config.new(url, server_port, mode))
base_dir.try do |dir|
start_server(Config.new(url, server_port, mode, dir))
end || (
start_server(Config.new(url, server_port, mode))
)
else
STDOUT.flush_on_newline = false
find_from_filesystem(Config.new(url, server_port, mode), query_options).each do |a|
Expand Down

0 comments on commit 58ce7ef

Please sign in to comment.