8000 README · ruby/optparse@bcc1b5f · GitHub
[go: up one dir, main page]

Skip to content

Commit bcc1b5f

Browse files
committed
README
1 parent f28c90c commit bcc1b5f

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

README.md

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
# Optparse
1+
# OptionParser
22

3-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/optparse`. To experiment with that code, run `bin/console` for an interactive prompt.
3+
OptionParser is a class for command-line option analysis. It is much more
4+
advanced, yet also easier to use, than GetoptLong, and is a more Ruby-oriented
5+
solution.
46

5-
TODO: Delete this and the text above, and describe your gem
7+
## Features
8+
9+
1. The argument specification and the code to handle it are written in the
10+
same place.
11+
2. It can output an option summary; you don't need to maintain this string
12+
separately.
13+
3. Optional and mandatory arguments are specified very gracefully.
14+
4. Arguments can be automatically converted to a specified class.
15+
5. Arguments can be restricted to a certain set.
616

717
## Installation
818

@@ -22,7 +32,21 @@ Or install it yourself as:
2232

2333
## Usage
2434

25-
TODO: Write usage instructions here
35+
```ruby
36+
require 'optparse'
37+
38+
options = {}
39+
OptionParser.new do |opts|
40+
opts.banner = "Usage: example.rb [options]"
41+
42+
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
43+
options[:verbose] = v
44+
end
45+
end.parse!
46+
47+
p options
48+
p ARGV
49+
```
2650

2751
## Development
2852

@@ -32,5 +56,5 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
3256

3357
## Contributing
3458

35-
Bug reports and pull requests are welcome on GitHub at https://github.com/hsbt/optparse.
59+
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/optparse.
3660

0 commit comments

Comments
 (0)
0