dotopts 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.index +1 -1
- data/README.md +21 -6
- data/lib/dotopts/api.rb +11 -1
- data/lib/dotopts/parser.rb +4 -0
- metadata +1 -1
data/.index
CHANGED
data/README.md
CHANGED
@@ -30,17 +30,23 @@ arguments when a matching command is invoked.
|
|
30
30
|
|
31
31
|
## Install
|
32
32
|
|
33
|
-
DotOpts can be install via
|
33
|
+
DotOpts can be install via RubyGems:
|
34
34
|
|
35
35
|
gem install dotopts
|
36
36
|
|
37
|
-
|
38
|
-
whether they have built-in support for DotOpts
|
39
|
-
to you `RUBYOPT` environment
|
37
|
+
There are two wasy to setup DotOpts for use by all Ruby tools (regardless
|
38
|
+
of whether they have built-in support for DotOpts or not). The most
|
39
|
+
univeral approach is to add `-rdotopts` to you `RUBYOPT` environment
|
40
|
+
variable.
|
40
41
|
|
41
42
|
export RUBYOPT="-rdotopts"
|
42
43
|
|
43
|
-
This ensures DotOpts is required whenever Ruby is used.
|
44
|
+
This ensures DotOpts is required whenever Ruby is used. The other
|
45
|
+
approach is to use Bundler by adding DotOpts to your project's Gemfile.
|
46
|
+
|
47
|
+
gem 'dotopts'
|
48
|
+
|
49
|
+
This will allow dotopts to run whenever using `bundle exec`.
|
44
50
|
|
45
51
|
|
46
52
|
## Usage
|
@@ -116,7 +122,7 @@ using regular expressions.
|
|
116
122
|
-r simplecov
|
117
123
|
```
|
118
124
|
|
119
|
-
|
125
|
+
### Tool Support
|
120
126
|
|
121
127
|
Ruby tool developers can support dotopts out-of-the-box simple by running
|
122
128
|
`require 'dotopts'` in their program before parsing the commandline. DotOpts
|
@@ -126,6 +132,15 @@ option parser.
|
|
126
132
|
|
127
133
|
## Development
|
128
134
|
|
135
|
+
### Suggestions & Contributions
|
136
|
+
|
137
|
+
DotOpts is a brand new application, and still rather wet behind the years, so to
|
138
|
+
speak. So your input is critical to making it better. Any and all suggestions and
|
139
|
+
contributions are much appreciated. If you have any ideas on how to improve DotOpts,
|
140
|
+
or find any flaws in its design that need address, please drop a comment on the
|
141
|
+
[Issues](http://github.com/rubyworks/dotopts/issues) page. Or even better, be proactive!
|
142
|
+
Fork the project submit a pull request. Thanks.
|
143
|
+
|
129
144
|
### Universal Solution?
|
130
145
|
|
131
146
|
It would be awesome if it were possible to have DotOpts apply to *all* executables,
|
data/lib/dotopts/api.rb
CHANGED
@@ -15,7 +15,7 @@ module DotOpts
|
|
15
15
|
if file
|
16
16
|
text = File.read(file)
|
17
17
|
parser = Parser.parse(text)
|
18
|
-
|
18
|
+
apply(parser.arguments, parser.environment)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -44,4 +44,14 @@ module DotOpts
|
|
44
44
|
nil
|
45
45
|
end
|
46
46
|
|
47
|
+
# Apply arguments and environment options.
|
48
|
+
#
|
49
|
+
# TODO: Support argument prepending in future version?
|
50
|
+
#
|
51
|
+
def self.apply(argv, env={})
|
52
|
+
puts argv.join(' ') if ENV['dotopts_debug']
|
53
|
+
env.each{ |k,v| ENV[k.to_s] = v.to_s }
|
54
|
+
ARGV.concat(argv)
|
55
|
+
end
|
56
|
+
|
47
57
|
end
|
data/lib/dotopts/parser.rb
CHANGED
@@ -23,6 +23,7 @@ module DotOpts
|
|
23
23
|
def initialize(text)
|
24
24
|
@text = text
|
25
25
|
@arguments = []
|
26
|
+
@environment = {}
|
26
27
|
end
|
27
28
|
|
28
29
|
#
|
@@ -31,6 +32,9 @@ module DotOpts
|
|
31
32
|
#
|
32
33
|
attr :arguments
|
33
34
|
|
35
|
+
#
|
36
|
+
attr :environment
|
37
|
+
|
34
38
|
#
|
35
39
|
def parse
|
36
40
|
lines = @text.lines.to_a
|