Skip to content

Commit

Permalink
Handle optional space in -L option (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
Blacksmoke16 authored Jan 1, 2022
1 parent f155670 commit 5b6920f
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ The built binary will be available as `./bin/oq`. This can be relocated elsewhe

```dockerfile
# Set an arg to store the oq version that should be installed.
ARG OQ_VERSION=1.3.1
ARG OQ_VERSION=1.3.2

# Grab the binary from the latest Github release and make it executable; placing it within /usr/local/bin. Can also put it elsewhere if you so desire.
RUN wget https://github.com/Blacksmoke16/oq/releases/download/v${OQ_VERSION}/oq-v${OQ_VERSION}-linux-x86_64 -O /usr/local/bin/oq && chmod +x /usr/local/bin/oq
Expand Down
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: oq
description: |
A performant, and portable jq wrapper thats facilitates the consumption and output of formats other than JSON; using jq filters to transform the data.
version: 1.3.1
version: 1.3.2

authors:
- George Dietrich <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion snap/snapcraft.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: oq
version: '1.3.1'
version: '1.3.2'
summary: A performant, and portable jq wrapper to support formats other than JSON
description: |
A performant, and portable jq wrapper thats facilitates the consumption and output of formats other than JSON; using jq filters to transform the data.
Expand Down
1 change: 1 addition & 0 deletions spec/assets/test.jq
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def increment: . + 1;
12 changes: 9 additions & 3 deletions spec/oq_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,15 @@ describe OQ do
end

describe "with the -L option" do
it "should be passed correctly" do
run_binary(input: SIMPLE_JSON_OBJECT, args: ["-L", "'/home/'", "."]) do |output|
output.should eq %({\n "name": "Jim"\n}\n)
it "should be passed correctly without a space" do
run_binary(args: ["-n", "-L#{__DIR__}/assets", %(import "test" as test; 9 | test::increment)]) do |output|
output.should eq %(10\n)
end
end

it "should be passed correctly with a space" do
run_binary(args: ["-n", "-L", "#{__DIR__}/assets", %(import "test" as test; 9 | test::increment)]) do |output|
output.should eq %(10\n)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.cr
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def run_binary(input : String | Process::Redirect | Nil = nil, name : String = "
status = Process.run(name, args, output: buffer_io, input: input_io, error: error_io)

if success
status.success?.should be_true, file: file, line: line
status.success?.should be_true, file: file, line: line, failure_message: error_io.to_s
else
status.success?.should_not be_true, file: file, line: line
status.success?.should_not be_true, file: file, line: line, failure_message: error_io.to_s
end

yield buffer_io.to_s, status, error_io.to_s
Expand Down
6 changes: 3 additions & 3 deletions src/oq.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require "./converters/*"

# A performant, and portable jq wrapper thats facilitates the consumption and output of formats other than JSON; using jq filters to transform the data.
module OQ
VERSION = "1.3.1"
VERSION = "1.3.2"

# The support formats that can be converted to/from.
enum Format
Expand Down Expand Up @@ -145,10 +145,10 @@ module OQ
# Register an at_exit handler to cleanup temp files.
at_exit { @tmp_files.each &.delete }

# Parse out --rawfile, --argfile, --slurpfile, and -f/--from-file before processing additional args
# Parse out --rawfile, --argfile, --slurpfile,-f/--from-file, and -L before processing additional args
# since these options use a file that should not be used as input.
self.consume_file_args input_args, "--rawfile", "--argfile", "--slurpfile"
self.consume_file_args input_args, "-f", "--from-file", count: 1
self.consume_file_args input_args, "-f", "--from-file", "-L", count: 1

# Also parse out --arg, and --argjson as they may include identifiers that also exist as a directory/file
# which would result in incorrect arg extraction.
Expand Down

0 comments on commit 5b6920f

Please sign in to comment.