httpdisk 0.2.0 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,54 +0,0 @@
1
- # manually load dependencies here since this is loaded standalone by bin
2
- require 'httpdisk/error'
3
- require 'httpdisk/version'
4
- require 'slop'
5
-
6
- module HTTPDisk
7
- # Slop parsing. This is broken out so we can run without require 'httpdisk'.
8
- module CliSlop
9
- def self.slop(args)
10
- slop = Slop.parse(args) do |o|
11
- o.banner = 'httpdisk [options] [url]'
12
-
13
- # similar to curl
14
- o.separator 'Similar to curl:'
15
- o.string '-d', '--data', 'HTTP POST data'
16
- o.array '-H', '--header', 'pass custom header(s) to server', delimiter: nil
17
- o.boolean '-i', '--include', 'include response headers in the output'
18
- o.integer '-m', '--max-time', 'maximum time allowed for the transfer'
19
- o.string '-o', '--output', 'write to file instead of stdout'
20
- o.string '-x', '--proxy', 'use host[:port] as proxy'
21
- o.string '-X', '--request', 'HTTP method to use'
22
- o.integer '--retry', 'retry request if problems occur'
23
- o.boolean '-s', '--silent', "silent mode (don't print errors)"
24
- o.string '-A', '--user-agent', 'send User-Agent to server'
25
-
26
- # from httpdisk
27
- o.separator 'Specific to httpdisk:'
28
- o.string '--dir', 'httpdisk cache directory (defaults to ~/httpdisk)'
29
- o.string '--expires', 'when to expire cached requests (ex: 1h, 2d, 3w)'
30
- o.boolean '--force', "don't read anything from cache (but still write)"
31
- o.boolean '--force-errors', "don't read errors from cache (but still write)"
32
- o.boolean '--status', 'show status for a url in the cache'
33
-
34
- # generic
35
- o.boolean '--version', 'show version' do
36
- puts "httpdisk #{HTTPDisk::VERSION}"
37
- exit
38
- end
39
- o.on '--help', 'show this help' do
40
- puts o
41
- exit
42
- end
43
- end
44
-
45
- raise Slop::Error, '' if args.empty?
46
- raise Slop::Error, 'no URL specified' if slop.args.empty?
47
- raise Slop::Error, 'more than one URL specified' if slop.args.length > 1
48
-
49
- slop.to_h.tap do
50
- _1[:url] = slop.args.first
51
- end
52
- end
53
- end
54
- end