diff --git a/README.md b/README.md index e000d372..fc320084 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,9 @@ Usage: noir Output: -f FORMAT, --format json Set output format - [plain/json/yaml/markdown-table/curl/httpie/oas2/oas3] + * plain yaml json jsonl markdown-table + * curl httpie oas2 oas3 + * only-url only-param only-header only-cookie -o PATH, --output out.txt Write result to file --set-pvalue VALUE Specifies the value of the identified parameter --include-path Include file path in the plain result @@ -105,12 +107,12 @@ Usage: noir --no-log Displaying only the results Deliver: - --send-req Send the results to the web request - --send-proxy http://proxy.. Send the results to the web request via http proxy - --send-es http://es.. Send the results to elasticsearch - --with-headers X-Header:Value Add Custom Headers to be Used in Deliver - --use-matchers string Delivers URLs that match a specific condition - --use-filters string Excludes URLs that match a specific condition + --send-req Send results to a web request + --send-proxy http://proxy.. Send results to a web request via an HTTP proxy + --send-es http://es.. Send results to Elasticsearch + --with-headers X-Header:Value Add custom headers to be included in the delivery + --use-matchers string Send URLs that match specific conditions to the Deliver + --use-filters string Exclude URLs that match specified conditions and send the rest to Deliver Technologies: -t TECHS, --techs rails,php Specify the technologies to use diff --git a/spec/unit_test/models/output_builder_spec.cr b/spec/unit_test/models/output_builder_spec.cr index 69d994f3..ddebdd8b 100644 --- a/spec/unit_test/models/output_builder_spec.cr +++ b/spec/unit_test/models/output_builder_spec.cr @@ -61,4 +61,9 @@ describe "Initialize" do object = OutputBuilderOnlyCookie.new options object.output_file.should eq("output.json") end + + it "OutputBuilderJsonl" do + object = OutputBuilderJsonl.new options + object.output_file.should eq("output.json") + end end diff --git a/src/models/noir.cr b/src/models/noir.cr index d9628fe2..8aa306da 100644 --- a/src/models/noir.cr +++ b/src/models/noir.cr @@ -154,10 +154,13 @@ class NoirRunner def report case options[:format] - when "json" - puts @endpoints.to_json when "yaml" puts @endpoints.to_yaml + when "json" + puts @endpoints.to_json + when "jsonl" + builder = OutputBuilderJsonl.new @options + builder.print @endpoints when "markdown-table" builder = OutputBuilderMarkdownTable.new @options builder.print @endpoints diff --git a/src/noir.cr b/src/noir.cr index 47c6129f..6ed0f326 100644 --- a/src/noir.cr +++ b/src/noir.cr @@ -20,7 +20,7 @@ OptionParser.parse do |parser| parser.separator "\n Output:".colorize(:blue) - parser.on "-f FORMAT", "--format json", "Set output format\n * plain json yaml markdown-table\n * curl httpie oas2 oas3\n * only-url only-param only-header only-cookie" { |var| noir_options[:format] = var } + parser.on "-f FORMAT", "--format json", "Set output format\n * plain yaml json jsonl markdown-table\n * curl httpie oas2 oas3\n * only-url only-param only-header only-cookie" { |var| noir_options[:format] = var } parser.on "-o PATH", "--output out.txt", "Write result to file" { |var| noir_options[:output] = var } parser.on "--set-pvalue VALUE", "Specifies the value of the identified parameter" { |var| noir_options[:set_pvalue] = var } parser.on "--include-path", "Include file path in the plain result" do diff --git a/src/output_builder/jsonl.cr b/src/output_builder/jsonl.cr new file mode 100644 index 00000000..49f1672f --- /dev/null +++ b/src/output_builder/jsonl.cr @@ -0,0 +1,10 @@ +require "../models/output_builder" +require "../models/endpoint" + +class OutputBuilderJsonl < OutputBuilder + def print(endpoints : Array(Endpoint)) + endpoints.each do |endpoint| + ob_puts endpoint.to_json + end + end +end