Skip to content

Commit

Permalink
Fix base uri param
Browse files Browse the repository at this point in the history
The previous definition was missing the argument specification.

When you don't specify that the option takes an argument, `OptionParser`
treats it as a boolean flag.

Additionally:
- Fix output
- Fix get_document
- Fix readme
- Improve backtrace output
  • Loading branch information
tagliala committed Jan 17, 2025
1 parent ee8445a commit 1b04139
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ client.ping or abort "No connection to Colore"

doc_id = client.generate_doc_id
file = File.new('foo.jpg')
content = f.read
content = file.read

# Store a file
conversion_callback = 'http:/localhost:10000/foo' # you should have a listener on this port
Expand Down
12 changes: 6 additions & 6 deletions bin/colore-client
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ REQUESTS = %w[
OptionParser.new do |opts|
opts.banner = 'Usage: colore_client -r {request} [opts]'
opts.on('-r', '--request NAME', REQUESTS, 'Request to perform') { |r| request = r }
opts.on('-u', '--base-uri', 'Base URI') { |u| base_uri = u }
opts.on('-u', '--base-uri BASE_URI', 'Base URI') { |u| base_uri = u }
opts.on('-a', '--app APP', 'Application name') { |a| app = a }
opts.on('-d', '--doc-id ID', 'Document id') { |d| doc_id = d }
opts.on('-v', '--version VERSION', 'Version id') { |v| version = v }
Expand Down Expand Up @@ -89,7 +89,7 @@ begin
when 'delete_version'
resp = client.delete_version doc_id: doc_id, version: version
when 'get_document'
resp = client.delete_document doc_id: doc_id, version: version, filename: filename
resp = client.get_document doc_id: doc_id, version: version, filename: File.basename(file)
if output_file
File.binwrite(output_file, resp)
resp = nil
Expand All @@ -107,11 +107,11 @@ begin
end

if resp.respond_to? :to_hash
resp.to_hash
puts resp.to_hash
else
write(resp)
puts resp
end
rescue Colore::Errors::APIError => e
puts "Received error from colore: #{e.http_code}, #{e.message}"
pp e.rsp_backtrace if backtrace
warn "Received error from Colore: #{e.http_code}, #{e.message}"
warn "Backtrace: #{e.rsp_backtrace.inspect}" if backtrace
end

0 comments on commit 1b04139

Please sign in to comment.