miniparse 0.3.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/CHANGELOG.md +27 -0
 - data/FAQ.md +5 -3
 - data/LICENSE.txt +1 -0
 - data/README.md +16 -19
 - data/badge_fun.md +68 -0
 - data/examples/ex01_simple.rb +1 -1
 - data/examples/ex02_options.rb +1 -1
 - data/examples/ex03_commands.rb +1 -1
 - data/examples/ex04_mixed.rb +1 -1
 - data/examples/ex05_block.rb +1 -1
 - data/examples/ex06_task_app.rb +1 -1
 - data/examples/ex07_controls.rb +2 -2
 - data/examples/ex08_app_simple.rb +4 -3
 - data/lib/miniparse/command.rb +3 -2
 - data/lib/miniparse/parser.rb +15 -20
 - data/lib/miniparse/version.rb +2 -2
 - data/miniparse.gemspec +3 -1
 - metadata +7 -5
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: d3d0c195e0ed48896bc0b7c358241d361dbcce6b
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: ff9d43c21dfd7c8eb4a6016a265deeb458b84790
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: e58e69168f86d2b1dcdb55386bbd15ef3587070645b198dce4d8c743ee9efcad76b550d22711687a27741221f7b7fc4d2f0d7d2491ab8a5041c365340cca07fb
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: e19e5e218b9d8c36a3d48abb98ac9c25628942e6c528a874322180b89515db76b382ecfb2c7af1e8979525e55e99d382449db175d5192bece07fea079eeb4d39
         
     | 
    
        data/CHANGELOG.md
    ADDED
    
    | 
         @@ -0,0 +1,27 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
             
     | 
| 
      
 2 
     | 
    
         
            +
            # Miniparse Change Log
         
     | 
| 
      
 3 
     | 
    
         
            +
            All MAJOR.MINOR changes to Miniparse will be documented in this file.
         
     | 
| 
      
 4 
     | 
    
         
            +
            This project uses an aproximation to [Semantic Versioning](http://semver.org/), 
         
     | 
| 
      
 5 
     | 
    
         
            +
            see [miniparse FAQ](https://github.com/jmrod4/miniparse/blob/master/FAQ.md) for details.
         
     | 
| 
      
 6 
     | 
    
         
            +
             
         
     | 
| 
      
 7 
     | 
    
         
            +
            ## [v0.4.0] - 2016-03-23
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            ### Public interface
         
     | 
| 
      
 10 
     | 
    
         
            +
            to gain in clarity
         
     | 
| 
      
 11 
     | 
    
         
            +
            - Parser#command_name replaces Parser#command
         
     | 
| 
      
 12 
     | 
    
         
            +
            - Parser#current_command_name replaces Parser#current_command
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            new feature
         
     | 
| 
      
 15 
     | 
    
         
            +
            - added Parser#add_program_description(...)
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            ### Improved
         
     | 
| 
      
 18 
     | 
    
         
            +
            - greatly improved source yard documentation (used by rubygems site) and used @private to guard the non-public interface
         
     | 
| 
      
 19 
     | 
    
         
            +
            - improved examples
         
     | 
| 
      
 20 
     | 
    
         
            +
            - modified app_simple example so that set_control is outside configure block and has a global effect
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            ### Fixed
         
     | 
| 
      
 23 
     | 
    
         
            +
            - added gemspec requeriment to Ruby 2.0 or later
         
     | 
| 
      
 24 
     | 
    
         
            +
            - fixed examples
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            ## [v0.3.0] - 2016-03-16
         
     | 
| 
      
 27 
     | 
    
         
            +
            first public gem release
         
     | 
    
        data/FAQ.md
    CHANGED
    
    | 
         @@ -5,7 +5,7 @@ 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            ### What's the meaning of _x.y.z_ in your version numbers?
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
      
 8 
     | 
    
         
            +
            For version 1.0.0 and following we use a [Semantic Versioning](http://semver.org/) like scheme of MAJOR.MINOR.PATCH:
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
            The MAJOR version numbers will only change when backwards incompatible changes are made to the public interface.
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
         @@ -13,7 +13,9 @@ The MINOR version number will change when adding new functionality or some exten 
     | 
|
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
            The PATCH number will change when fixing bugs or implementing internal or minor improvements. No changes will be made to the public interface.
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
     | 
    
         
            -
            Additionally a `b` will be added for beta  
     | 
| 
      
 16 
     | 
    
         
            +
            Additionally a `b` will be added for beta or a `pre` for pre-release versions.
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            NOTE: Until 1.0 version is released the library is considered in an _unstable_ state and any changes to the public interface will change only the MINOR version number.
         
     | 
| 
       17 
19 
     | 
    
         | 
| 
       18 
20 
     | 
    
         
             
            ---
         
     | 
| 
       19 
21 
     | 
    
         | 
| 
         @@ -23,7 +25,7 @@ At the moment the complete public interface is restricted to the class Parser, t 
     | 
|
| 
       23 
25 
     | 
    
         | 
| 
       24 
26 
     | 
    
         
             
            You can find the complete specification in the public methods and constants on these files:
         
     | 
| 
       25 
27 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
              * [miniparse.rb](https://github.com/jmrod4/miniparse/blob/master/lib/miniparse/constants.rb)
         
     | 
| 
      
 28 
     | 
    
         
            +
              * [miniparse/constants.rb](https://github.com/jmrod4/miniparse/blob/master/lib/miniparse/constants.rb)
         
     | 
| 
       27 
29 
     | 
    
         | 
| 
       28 
30 
     | 
    
         
             
              * [miniparse/parser.rb](https://github.com/jmrod4/miniparse/blob/master/lib/miniparse/parser.rb)
         
     | 
| 
       29 
31 
     | 
    
         | 
    
        data/LICENSE.txt
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,9 +1,10 @@ 
     | 
|
| 
       1 
1 
     | 
    
         | 
| 
       2 
     | 
    
         
            -
            #  
     | 
| 
      
 2 
     | 
    
         
            +
            # miniparse [](https://rubygems.org/gems/miniparse)
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
            **Miniparse is an easy to use yet flexible and powerful  
     | 
| 
      
 4 
     | 
    
         
            +
            **Miniparse is an easy to use yet flexible and powerful Ruby library for parsing command-line options.**
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            The main objective of this implementation is to get minimun boiler plate but keep ease of use and a self documenting specification. 
         
     | 
| 
       7 
8 
     | 
    
         | 
| 
       8 
9 
     | 
    
         
             
            Additionally the library is quite flexible and allows a lot of customization but always with sane defaults so **you don't need to learn nothing to start using it**.
         
     | 
| 
       9 
10 
     | 
    
         | 
| 
         @@ -11,23 +12,17 @@ Additionally the library is quite flexible and allows a lot of customization but 
     | 
|
| 
       11 
12 
     | 
    
         | 
| 
       12 
13 
     | 
    
         
             
            Please find below a short but meaningful example, then you can **[get more examples](https://github.com/jmrod4/miniparse/tree/master/examples)** at [Github miniparse repository](https://github.com/jmrod4/miniparse).
         
     | 
| 
       13 
14 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
            You can find  
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
            And finally, for the source files for the complete public interface you can see the class Parser in:
         
     | 
| 
      
 15 
     | 
    
         
            +
            You can also find a nice autogenerated documentation from the current gem at  http://www.rubydoc.info/gems/miniparse/
         
     | 
| 
       17 
16 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
      
 17 
     | 
    
         
            +
            And finally, the source files for the complete public interface are:
         
     | 
| 
       19 
18 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
      
 19 
     | 
    
         
            +
              * the class Parser at [miniparse/parser.rb](https://github.com/jmrod4/miniparse/blob/master/lib/miniparse/parser.rb)
         
     | 
| 
       21 
20 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
              * [miniparse/control.rb](https://github.com/jmrod4/miniparse/blob/master/lib/miniparse/control.rb)
         
     | 
| 
       23 
     | 
    
         
            -
              
         
     | 
| 
       24 
     | 
    
         
            -
            And the constants in: 
         
     | 
| 
      
 21 
     | 
    
         
            +
              * the control class methods at [miniparse/control.rb](https://github.com/jmrod4/miniparse/blob/master/lib/miniparse/control.rb)
         
     | 
| 
       25 
22 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
              * [miniparse.rb](https://github.com/jmrod4/miniparse/blob/master/lib/miniparse/constants.rb)
         
     | 
| 
      
 23 
     | 
    
         
            +
              * the constants in [miniparse/constants.rb](https://github.com/jmrod4/miniparse/blob/master/lib/miniparse/constants.rb)
         
     | 
| 
       27 
24 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
              * [miniparse/app.rb](https://github.com/jmrod4/miniparse/blob/master/lib/miniparse/app.rb)		
         
     | 
| 
      
 25 
     | 
    
         
            +
              * and if you use the optional App module you can find the source in [miniparse/app.rb](https://github.com/jmrod4/miniparse/blob/master/lib/miniparse/app.rb)		
         
     | 
| 
       31 
26 
     | 
    
         | 
| 
       32 
27 
     | 
    
         
             
            ## Simple Example
         
     | 
| 
       33 
28 
     | 
    
         | 
| 
         @@ -68,15 +63,15 @@ or even get the auto generated help 
     | 
|
| 
       68 
63 
     | 
    
         | 
| 
       69 
64 
     | 
    
         
             
            ## Installation
         
     | 
| 
       70 
65 
     | 
    
         | 
| 
       71 
     | 
    
         
            -
            You can install it as an standard  
     | 
| 
      
 66 
     | 
    
         
            +
            You can install it as an standard Ruby gem with
         
     | 
| 
       72 
67 
     | 
    
         | 
| 
       73 
68 
     | 
    
         
             
                $ gem install miniparse
         
     | 
| 
       74 
69 
     | 
    
         | 
| 
       75 
     | 
    
         
            -
            then to use you can require it adding the following to the top of your  
     | 
| 
      
 70 
     | 
    
         
            +
            then to use you can require it adding the following to the top of your Ruby source file
         
     | 
| 
       76 
71 
     | 
    
         | 
| 
       77 
72 
     | 
    
         
             
                require 'miniparse'
         
     | 
| 
       78 
73 
     | 
    
         | 
| 
       79 
     | 
    
         
            -
            ##  
     | 
| 
      
 74 
     | 
    
         
            +
            ## FAQ
         
     | 
| 
       80 
75 
     | 
    
         | 
| 
       81 
76 
     | 
    
         
             
            There is a FAQ available at https://github.com/jmrod4/miniparse/blob/master/FAQ.md
         
     | 
| 
       82 
77 
     | 
    
         | 
| 
         @@ -94,6 +89,8 @@ After checking out the repo you can: 
     | 
|
| 
       94 
89 
     | 
    
         | 
| 
       95 
90 
     | 
    
         
             
            ## License
         
     | 
| 
       96 
91 
     | 
    
         | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
      
 92 
     | 
    
         
            +
            Copryright 2016 Juanma Rodriguez
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
            This library is copyrighted software and it can be used and distributed as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
         
     | 
| 
       98 
95 
     | 
    
         | 
| 
       99 
96 
     | 
    
         
             
            You can find the source code at https://github.com/jmrod4/miniparse.
         
     | 
    
        data/badge_fun.md
    ADDED
    
    | 
         @@ -0,0 +1,68 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
             
     | 
| 
      
 2 
     | 
    
         
            +
            # miniparse   [](https://github.com/jmrod4/miniparse/issues) [](https://github.com/jmrod4/miniparse) [](https://rubygems.org/gems/miniparse)
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            **Miniparse is an easy to use yet flexible and powerful Ruby library for parsing command-line options.**
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            # miniparse
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            **Miniparse is an easy to use yet flexible and powerful Ruby library for parsing command-line options.**
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            [](https://github.com/jmrod4/miniparse/issues) [](https://github.com/jmrod4/miniparse) [](https://rubygems.org/gems/miniparse)
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            # Miniparse Badges
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            Some of the available badges for this project, just to have a bit of graphic fun
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            ## a selection with links
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            ## fury.io
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            ### GitHub
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            [](https://badge.fury.io/gh/jmrod4%2Fminiparse) 
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            ### Gem
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            [](https://badge.fury.io/rb/miniparse)
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            ## shields.io
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            ### GitHub
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            []()
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            []()
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
            []()
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            []()
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
            []()
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            []()
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
            []()
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
            []()
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
            ### Gem
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            []()
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
            []()
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
            []()
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
            []()
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
            []()
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
            #### User
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
            []()
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
            ### Custom
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
            []()
         
     | 
    
        data/examples/ex01_simple.rb
    CHANGED
    
    | 
         @@ -18,6 +18,6 @@ end 
     | 
|
| 
       18 
18 
     | 
    
         
             
            puts "args     #{parser.args.inspect}"
         
     | 
| 
       19 
19 
     | 
    
         
             
            puts "options  #{parser.options.inspect}"
         
     | 
| 
       20 
20 
     | 
    
         
             
            # for commands
         
     | 
| 
       21 
     | 
    
         
            -
            puts "parsed command  #{parser. 
     | 
| 
      
 21 
     | 
    
         
            +
            puts "parsed command  #{parser.command_name.inspect}"
         
     | 
| 
       22 
22 
     | 
    
         
             
            puts "command args    #{parser.command_args.inspect}"
         
     | 
| 
       23 
23 
     | 
    
         
             
            puts "command options #{parser.command_options.inspect}"
         
     | 
    
        data/examples/ex02_options.rb
    CHANGED
    
    | 
         @@ -26,6 +26,6 @@ parser.parse(ARGV) 
     | 
|
| 
       26 
26 
     | 
    
         
             
            puts "args     #{parser.args.inspect}"
         
     | 
| 
       27 
27 
     | 
    
         
             
            puts "options  #{parser.options.inspect}"
         
     | 
| 
       28 
28 
     | 
    
         
             
            # for commands
         
     | 
| 
       29 
     | 
    
         
            -
            puts "parsed command  #{parser. 
     | 
| 
      
 29 
     | 
    
         
            +
            puts "parsed command  #{parser.command_name.inspect}"
         
     | 
| 
       30 
30 
     | 
    
         
             
            puts "command args    #{parser.command_args.inspect}"
         
     | 
| 
       31 
31 
     | 
    
         
             
            puts "command options #{parser.command_options.inspect}"
         
     | 
    
        data/examples/ex03_commands.rb
    CHANGED
    
    | 
         @@ -19,6 +19,6 @@ parser.parse(ARGV) 
     | 
|
| 
       19 
19 
     | 
    
         
             
            puts "args     #{parser.args.inspect}"
         
     | 
| 
       20 
20 
     | 
    
         
             
            puts "options  #{parser.options.inspect}"
         
     | 
| 
       21 
21 
     | 
    
         
             
            # for commands
         
     | 
| 
       22 
     | 
    
         
            -
            puts "parsed command  #{parser. 
     | 
| 
      
 22 
     | 
    
         
            +
            puts "parsed command  #{parser.command_name.inspect}"
         
     | 
| 
       23 
23 
     | 
    
         
             
            puts "command args    #{parser.command_args.inspect}"
         
     | 
| 
       24 
24 
     | 
    
         
             
            puts "command options #{parser.command_options.inspect}"
         
     | 
    
        data/examples/ex04_mixed.rb
    CHANGED
    
    | 
         @@ -32,6 +32,6 @@ parser.parse(ARGV) 
     | 
|
| 
       32 
32 
     | 
    
         
             
            puts "args     #{parser.args.inspect}"
         
     | 
| 
       33 
33 
     | 
    
         
             
            puts "options  #{parser.options.inspect}"
         
     | 
| 
       34 
34 
     | 
    
         
             
            # for commands
         
     | 
| 
       35 
     | 
    
         
            -
            puts "parsed command  #{parser. 
     | 
| 
      
 35 
     | 
    
         
            +
            puts "parsed command  #{parser.command_name.inspect}"
         
     | 
| 
       36 
36 
     | 
    
         
             
            puts "command args    #{parser.command_args.inspect}"
         
     | 
| 
       37 
37 
     | 
    
         
             
            puts "command options #{parser.command_options.inspect}"
         
     | 
    
        data/examples/ex05_block.rb
    CHANGED
    
    | 
         @@ -26,6 +26,6 @@ parser.parse(ARGV) 
     | 
|
| 
       26 
26 
     | 
    
         
             
            puts "args     #{parser.args.inspect}"
         
     | 
| 
       27 
27 
     | 
    
         
             
            puts "options  #{parser.options.inspect}"
         
     | 
| 
       28 
28 
     | 
    
         
             
            # for commands
         
     | 
| 
       29 
     | 
    
         
            -
            puts "parsed command  #{parser. 
     | 
| 
      
 29 
     | 
    
         
            +
            puts "parsed command  #{parser.command_name.inspect}"
         
     | 
| 
       30 
30 
     | 
    
         
             
            puts "command args    #{parser.command_args.inspect}"
         
     | 
| 
       31 
31 
     | 
    
         
             
            puts "command options #{parser.command_options.inspect}"
         
     | 
    
        data/examples/ex06_task_app.rb
    CHANGED
    
    | 
         @@ -28,7 +28,7 @@ parser.parse ARGV 
     | 
|
| 
       28 
28 
     | 
    
         
             
            puts "args     #{parser.args.inspect}"
         
     | 
| 
       29 
29 
     | 
    
         
             
            puts "options  #{parser.options.inspect}"
         
     | 
| 
       30 
30 
     | 
    
         
             
            # for commands
         
     | 
| 
       31 
     | 
    
         
            -
            puts "parsed command  #{parser. 
     | 
| 
      
 31 
     | 
    
         
            +
            puts "parsed command  #{parser.command_name.inspect}"
         
     | 
| 
       32 
32 
     | 
    
         
             
            puts "command args    #{parser.command_args.inspect}"
         
     | 
| 
       33 
33 
     | 
    
         
             
            puts "command options #{parser.command_options.inspect}"
         
     | 
| 
       34 
34 
     | 
    
         | 
    
        data/examples/ex07_controls.rb
    CHANGED
    
    | 
         @@ -2,7 +2,7 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            require 'miniparse'
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
            # following is just a copy of the controls defined in  
     | 
| 
      
 5 
     | 
    
         
            +
            # following is just a copy of the controls defined in constants.rb
         
     | 
| 
       6 
6 
     | 
    
         
             
            # you don't need to specify all, only the ones you want to change (maybe none)
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
            Miniparse.set_control( {
         
     | 
| 
         @@ -58,6 +58,6 @@ end 
     | 
|
| 
       58 
58 
     | 
    
         
             
            puts "args     #{parser.args.inspect}"
         
     | 
| 
       59 
59 
     | 
    
         
             
            puts "options  #{parser.options.inspect}"
         
     | 
| 
       60 
60 
     | 
    
         
             
            # for commands
         
     | 
| 
       61 
     | 
    
         
            -
            puts "parsed command  #{parser. 
     | 
| 
      
 61 
     | 
    
         
            +
            puts "parsed command  #{parser.command_name.inspect}"
         
     | 
| 
       62 
62 
     | 
    
         
             
            puts "command args    #{parser.command_args.inspect}"
         
     | 
| 
       63 
63 
     | 
    
         
             
            puts "command options #{parser.command_options.inspect}"
         
     | 
    
        data/examples/ex08_app_simple.rb
    CHANGED
    
    | 
         @@ -1,9 +1,10 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require "miniparse/app"
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            Miniparse.set_control(
         
     | 
| 
      
 4 
     | 
    
         
            +
                autoshortable: true,
         
     | 
| 
      
 5 
     | 
    
         
            +
                )
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
       3 
7 
     | 
    
         
             
            App.configure_parser do |parser|
         
     | 
| 
       4 
     | 
    
         
            -
              Miniparse.set_control(
         
     | 
| 
       5 
     | 
    
         
            -
                  autoshortable: true,
         
     | 
| 
       6 
     | 
    
         
            -
                  )
         
     | 
| 
       7 
8 
     | 
    
         
             
              parser.add_program_description "my program help introduction\n"
         
     | 
| 
       8 
9 
     | 
    
         
             
              parser.add_option("--list", "list something")
         
     | 
| 
       9 
10 
     | 
    
         
             
              parser.parse ARGV
         
     | 
    
        data/lib/miniparse/command.rb
    CHANGED
    
    | 
         @@ -84,11 +84,12 @@ end 
     | 
|
| 
       84 
84 
     | 
    
         | 
| 
       85 
85 
     | 
    
         | 
| 
       86 
86 
     | 
    
         | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
            # @private  
         
     | 
| 
       87 
89 
     | 
    
         
             
            # TODO FEATURE consider doing unambiguous matches for shortened options
         
     | 
| 
       88 
90 
     | 
    
         
             
            # TODO FEATURE consider the option default value setting the type
         
     | 
| 
       89 
     | 
    
         
            -
            # @private  
         
     | 
| 
       90 
91 
     | 
    
         
             
            class Option < Command
         
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
       92 
93 
     | 
    
         
             
              attr_reader :value, :shortable
         
     | 
| 
       93 
94 
     | 
    
         | 
| 
       94 
95 
     | 
    
         
             
              def check(arg)
         
     | 
    
        data/lib/miniparse/parser.rb
    CHANGED
    
    | 
         @@ -92,11 +92,9 @@ class Parser 
     | 
|
| 
       92 
92 
     | 
    
         
             
                try_argument do
         
     | 
| 
       93 
93 
     | 
    
         
             
                  global_argv, cmd_name, cmd_argv = commander.split_argv(argv)
         
     | 
| 
       94 
94 
     | 
    
         
             
                  @args = global_broker.parse_argv(global_argv)
         
     | 
| 
       95 
     | 
    
         
            -
                   
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
                   
     | 
| 
       98 
     | 
    
         
            -
                  if Miniparse.control(:raise_global_args) && (! args.empty?)
         
     | 
| 
       99 
     | 
    
         
            -
                    # FIXME review this logic later
         
     | 
| 
      
 95 
     | 
    
         
            +
                  
         
     | 
| 
      
 96 
     | 
    
         
            +
                  commander.parse_argv(cmd_name, cmd_argv)    if cmd_name
         
     | 
| 
      
 97 
     | 
    
         
            +
                  if Miniparse.control(:raise_global_args) && !args.empty?
         
     | 
| 
       100 
98 
     | 
    
         
             
                    error = current_command_name  ?  "unrecognized command"  :  "extra arguments"
         
     | 
| 
       101 
99 
     | 
    
         
             
                    raise ArgumentError, "#{error} '#{args[0]}'"
         
     | 
| 
       102 
100 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -106,7 +104,6 @@ class Parser 
     | 
|
| 
       106 
104 
     | 
    
         | 
| 
       107 
105 
     | 
    
         
             
              # @return [string] a help message with the short descriptions
         
     | 
| 
       108 
106 
     | 
    
         
             
              def help_desc
         
     | 
| 
       109 
     | 
    
         
            -
                #FIXME
         
     | 
| 
       110 
107 
     | 
    
         
             
                text = ""
         
     | 
| 
       111 
108 
     | 
    
         
             
                if (global = global_broker.help_desc).size > 0
         
     | 
| 
       112 
109 
     | 
    
         
             
                  text += "\nOptions:\n"
         
     | 
| 
         @@ -118,7 +115,6 @@ class Parser 
     | 
|
| 
       118 
115 
     | 
    
         | 
| 
       119 
116 
     | 
    
         
             
              # @return [string] a usage message
         
     | 
| 
       120 
117 
     | 
    
         
             
              def help_usage
         
     | 
| 
       121 
     | 
    
         
            -
                #FIXME
         
     | 
| 
       122 
118 
     | 
    
         
             
                if Miniparse.control(:detailed_usage)
         
     | 
| 
       123 
119 
     | 
    
         
             
                  right_text = @global_broker.help_usage
         
     | 
| 
       124 
120 
     | 
    
         
             
                elsif current_command_name
         
     | 
| 
         @@ -126,10 +122,12 @@ class Parser 
     | 
|
| 
       126 
122 
     | 
    
         
             
                else
         
     | 
| 
       127 
123 
     | 
    
         
             
                  right_text = "[options]"
         
     | 
| 
       128 
124 
     | 
    
         
             
                end
         
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
       129 
126 
     | 
    
         
             
                if current_command_name
         
     | 
| 
       130 
127 
     | 
    
         
             
                  right_text += " <command> [command_options]"
         
     | 
| 
       131 
128 
     | 
    
         
             
                end
         
     | 
| 
       132 
129 
     | 
    
         
             
                right_text += " <args>"
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
       133 
131 
     | 
    
         
             
                Miniparse.help_usage_format(right_text)
         
     | 
| 
       134 
132 
     | 
    
         
             
              end
         
     | 
| 
       135 
133 
     | 
    
         | 
| 
         @@ -141,19 +139,16 @@ protected 
     | 
|
| 
       141 
139 
     | 
    
         
             
                commander.current_broker || global_broker
         
     | 
| 
       142 
140 
     | 
    
         
             
              end
         
     | 
| 
       143 
141 
     | 
    
         | 
| 
       144 
     | 
    
         
            -
              def try_argument
         
     | 
| 
       145 
     | 
    
         
            -
                 
     | 
| 
       146 
     | 
    
         
            -
             
     | 
| 
       147 
     | 
    
         
            -
             
     | 
| 
       148 
     | 
    
         
            -
                 
     | 
| 
       149 
     | 
    
         
            -
             
     | 
| 
       150 
     | 
    
         
            -
             
     | 
| 
       151 
     | 
    
         
            -
             
     | 
| 
       152 
     | 
    
         
            -
             
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
       154 
     | 
    
         
            -
                  # (#{except.backtrace[-1]})")
         
     | 
| 
       155 
     | 
    
         
            -
                  exit ERR_ARGUMENT
         
     | 
| 
       156 
     | 
    
         
            -
                end
         
     | 
| 
      
 142 
     | 
    
         
            +
              def try_argument(&block)
         
     | 
| 
      
 143 
     | 
    
         
            +
                block.call
         
     | 
| 
      
 144 
     | 
    
         
            +
              rescue ArgumentError => except
         
     | 
| 
      
 145 
     | 
    
         
            +
                raise    unless Miniparse.control(:rescue_argument_error)
         
     | 
| 
      
 146 
     | 
    
         
            +
                prg = File.basename($PROGRAM_NAME)
         
     | 
| 
      
 147 
     | 
    
         
            +
                $stderr.puts "#{prg}: error: #{except.message}"
         
     | 
| 
      
 148 
     | 
    
         
            +
                $stderr.puts
         
     | 
| 
      
 149 
     | 
    
         
            +
                $stderr.puts help_usage
         
     | 
| 
      
 150 
     | 
    
         
            +
                # (#{except.backtrace[-1]})")
         
     | 
| 
      
 151 
     | 
    
         
            +
                exit ERR_ARGUMENT
         
     | 
| 
       157 
152 
     | 
    
         
             
              end
         
     | 
| 
       158 
153 
     | 
    
         | 
| 
       159 
154 
     | 
    
         
             
            end
         
     | 
    
        data/lib/miniparse/version.rb
    CHANGED
    
    
    
        data/miniparse.gemspec
    CHANGED
    
    | 
         @@ -9,7 +9,7 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       9 
9 
     | 
    
         
             
              spec.authors       = ["Juanma Rodriguez"]
         
     | 
| 
       10 
10 
     | 
    
         
             
              spec.email         = ["jmrod4@gmail.com"]
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
              spec.summary       = %q{ 
     | 
| 
      
 12 
     | 
    
         
            +
              spec.summary       = %q{miniparse is an easy to use yet flexible and powerful Ruby library for parsing command-line options.}
         
     | 
| 
       13 
13 
     | 
    
         
             
            #  spec.description   = %q{TODO: Write a longer description or delete this line.}
         
     | 
| 
       14 
14 
     | 
    
         
             
              spec.homepage      = "https://github.com/jmrod4/miniparse"
         
     | 
| 
       15 
15 
     | 
    
         
             
              spec.license       = "MIT"
         
     | 
| 
         @@ -26,6 +26,8 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       26 
26 
     | 
    
         
             
              spec.bindir        = "exe"
         
     | 
| 
       27 
27 
     | 
    
         
             
              spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
         
     | 
| 
       28 
28 
     | 
    
         
             
              spec.require_paths = ["lib"]
         
     | 
| 
      
 29 
     | 
    
         
            +
              
         
     | 
| 
      
 30 
     | 
    
         
            +
              spec.required_ruby_version = "~> 2.0"
         
     | 
| 
       29 
31 
     | 
    
         | 
| 
       30 
32 
     | 
    
         
             
              spec.add_development_dependency "bundler", "~> 1.11"
         
     | 
| 
       31 
33 
     | 
    
         
             
              spec.add_development_dependency "rake", "~> 10.0"
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: miniparse
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.4.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Juanma Rodriguez
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2016-03- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2016-03-23 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -77,11 +77,13 @@ files: 
     | 
|
| 
       77 
77 
     | 
    
         
             
            - ".rspec"
         
     | 
| 
       78 
78 
     | 
    
         
             
            - ".travis.yml"
         
     | 
| 
       79 
79 
     | 
    
         
             
            - ".yardopts"
         
     | 
| 
      
 80 
     | 
    
         
            +
            - CHANGELOG.md
         
     | 
| 
       80 
81 
     | 
    
         
             
            - FAQ.md
         
     | 
| 
       81 
82 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       82 
83 
     | 
    
         
             
            - LICENSE.txt
         
     | 
| 
       83 
84 
     | 
    
         
             
            - README.md
         
     | 
| 
       84 
85 
     | 
    
         
             
            - Rakefile
         
     | 
| 
      
 86 
     | 
    
         
            +
            - badge_fun.md
         
     | 
| 
       85 
87 
     | 
    
         
             
            - bin/console
         
     | 
| 
       86 
88 
     | 
    
         
             
            - bin/setup
         
     | 
| 
       87 
89 
     | 
    
         
             
            - examples/ex01_simple.rb
         
     | 
| 
         @@ -114,9 +116,9 @@ require_paths: 
     | 
|
| 
       114 
116 
     | 
    
         
             
            - lib
         
     | 
| 
       115 
117 
     | 
    
         
             
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
       116 
118 
     | 
    
         
             
              requirements:
         
     | 
| 
       117 
     | 
    
         
            -
              - - " 
     | 
| 
      
 119 
     | 
    
         
            +
              - - "~>"
         
     | 
| 
       118 
120 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       119 
     | 
    
         
            -
                  version: '0'
         
     | 
| 
      
 121 
     | 
    
         
            +
                  version: '2.0'
         
     | 
| 
       120 
122 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       121 
123 
     | 
    
         
             
              requirements:
         
     | 
| 
       122 
124 
     | 
    
         
             
              - - ">="
         
     | 
| 
         @@ -127,7 +129,7 @@ rubyforge_project: 
     | 
|
| 
       127 
129 
     | 
    
         
             
            rubygems_version: 2.4.8
         
     | 
| 
       128 
130 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       129 
131 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       130 
     | 
    
         
            -
            summary:  
     | 
| 
      
 132 
     | 
    
         
            +
            summary: miniparse is an easy to use yet flexible and powerful Ruby library for parsing
         
     | 
| 
       131 
133 
     | 
    
         
             
              command-line options.
         
     | 
| 
       132 
134 
     | 
    
         
             
            test_files: []
         
     | 
| 
       133 
135 
     | 
    
         
             
            has_rdoc: 
         
     |