Skip to content

Commit

Permalink
Add ony-url format (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
hahwul committed Jan 10, 2024
1 parent 7761c97 commit 2d0a0d1
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
5 changes: 5 additions & 0 deletions spec/unit_test/models/output_builder_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,9 @@ describe "Initialize" do
object = OutputBuilderOas3.new options
object.output_file.should eq("output.json")
end

it "OutputBuilderOnlyUrl" do
object = OutputBuilderOnlyUrl.new options
object.output_file.should eq("output.json")
end
end
2 changes: 1 addition & 1 deletion src/analyzer/analyzers/analyzer_example.cr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AnalyzerExample < Analyzer
next if File.directory?(path)
if File.exists?(path)
File.open(path, "r", encoding: "utf-8", invalid: :skip) do |file|
file.each_line.with_index do |line, index|
file.each_line.with_index do |_, _|
# For example (Add endpoint to result)
# endpoint = Endpoint.new("/", "GET")
# details = Details.new(PathInfo.new(path, index + 1))
Expand Down
3 changes: 3 additions & 0 deletions src/models/noir.cr
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ class NoirRunner
when "oas3"
buidler = OutputBuilderOas3.new @options
buidler.print @endpoints
when "only-url"
builder = OutputBuilderOnlyUrl.new @options
builder.print @endpoints
else
builder = OutputBuilderCommon.new @options
builder.print @endpoints
Expand Down
2 changes: 1 addition & 1 deletion src/noir.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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/curl/httpie/oas2/oas3]" { |var| noir_options[:format] = var }
parser.on "-f FORMAT", "--format json", "Set output format\n * plain json yaml markdown-table\n * curl httpie only-url\n * oas2 oas3" { |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
Expand Down
12 changes: 12 additions & 0 deletions src/output_builder/only-url.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require "../models/output_builder"
require "../models/endpoint"

class OutputBuilderOnlyUrl < OutputBuilder
def print(endpoints : Array(Endpoint))
endpoints.each do |endpoint|
baked = bake_endpoint(endpoint.url, endpoint.params)
r_url = baked[:url].colorize(:light_yellow).toggle(@is_color)
ob_puts "#{r_url}"
end
end
end

0 comments on commit 2d0a0d1

Please sign in to comment.