From d0a280f78b6e724a0800b0b11ee467bf615b7d3b Mon Sep 17 00:00:00 2001 From: y2k2mt Date: Thu, 24 Nov 2022 23:41:09 +0900 Subject: [PATCH 1/2] Add option for base_dir --- src/cli.cr | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/cli.cr b/src/cli.cr index 90a8af9..6dfc0f7 100644 --- a/src/cli.cr +++ b/src/cli.cr @@ -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| @@ -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 @@ -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| From 121f9e925d31c3e52a03234399fab88d5aab2739 Mon Sep 17 00:00:00 2001 From: y2k2mt Date: Thu, 24 Nov 2022 23:41:21 +0900 Subject: [PATCH 2/2] Format --- src/cli.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli.cr b/src/cli.cr index 6dfc0f7..c0f7495 100644 --- a/src/cli.cr +++ b/src/cli.cr @@ -69,7 +69,7 @@ end base_url.try do |url| if (query_options.empty?) base_dir.try do |dir| - start_server(Config.new(url, server_port, mode,dir)) + start_server(Config.new(url, server_port, mode, dir)) end || ( start_server(Config.new(url, server_port, mode)) )