gli 2.9.0 → 2.10.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/README.rdoc +2 -1
- data/features/step_definitions/todo_steps.rb +4 -0
- data/features/support/env.rb +1 -0
- data/features/todo.feature +32 -0
- data/lib/gli/app.rb +11 -0
- data/lib/gli/command.rb +2 -0
- data/lib/gli/command_support.rb +2 -1
- data/lib/gli/dsl.rb +2 -1
- data/lib/gli/version.rb +1 -1
- data/test/apps/todo/bin/todo +1 -0
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: bc8b2ac1abb69495f8096899fbb4da56b2e85d32
         | 
| 4 | 
            +
              data.tar.gz: ce4f47438626b06fbd4fcf4b714a5257b63a2ec5
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 1d9e77187528594f30d47c0dca4cdef47a1dc01fbc35657e0bfec3441a20b1d37d87dccecc4015957bf78c1055ff4ce9a0cb0b728b1e97305b6c8936ba82f2c2
         | 
| 7 | 
            +
              data.tar.gz: 81eb28d1e7b564fed156a69fa0159bd4236bffec82d51bf1c5874c6d6a521eb8f24ce1ee3f156ff9445a504311b9deb83deb059ab27120c079b04e8578b286cf
         | 
    
        data/README.rdoc
    CHANGED
    
    | @@ -3,7 +3,7 @@ | |
| 3 3 | 
             
            GLI is the best way to make a "command-suite" command-line application, e.g. one like <tt>git</tt> (for the best way to make a
         | 
| 4 4 | 
             
            simpler command-line application, check out methadone[http://www.github.com/davetron5000/methadone]).
         | 
| 5 5 |  | 
| 6 | 
            -
            GLI allows you to make a  | 
| 6 | 
            +
            GLI allows you to make a polished, easy-to-maintain command-line application without a lot
         | 
| 7 7 | 
             
            of syntax, but without restricting you in any way from the power of +OptionParser+.
         | 
| 8 8 |  | 
| 9 9 | 
             
            * {Overview}[http://davetron5000.github.com/gli]
         | 
| @@ -79,6 +79,7 @@ Known to work on | |
| 79 79 | 
             
            * 1.9.2
         | 
| 80 80 | 
             
            * 1.9.3
         | 
| 81 81 | 
             
            * 2.0.0
         | 
| 82 | 
            +
            * 2.1.0
         | 
| 82 83 | 
             
            * Ruby Enterprise Edition 1.8.7
         | 
| 83 84 | 
             
            * Rubinius 1.0.1
         | 
| 84 85 | 
             
            * JRuby 1.6.4 
         | 
| @@ -18,6 +18,10 @@ Given /^the todo app is coded to wrap text only for tty$/ do | |
| 18 18 | 
             
              ENV['TODO_WRAP_HELP_TEXT'] = 'tty_only'
         | 
| 19 19 | 
             
            end
         | 
| 20 20 |  | 
| 21 | 
            +
            Given /^the todo app is coded to hide commands without description$/ do
         | 
| 22 | 
            +
              ENV['HIDE_COMMANDS_WITHOUT_DESC'] = 'true'
         | 
| 23 | 
            +
            end
         | 
| 24 | 
            +
             | 
| 21 25 | 
             
            Given /^a clean home directory$/ do
         | 
| 22 26 | 
             
              FileUtils.rm_rf File.join(ENV['HOME'],'gli_test_todo.rc')
         | 
| 23 27 | 
             
            end
         | 
    
        data/features/support/env.rb
    CHANGED
    
    
    
        data/features/todo.feature
    CHANGED
    
    | @@ -144,6 +144,38 @@ Feature: The todo app has a nice user interface | |
| 144 144 | 
             
                    chained2, ch2 - 
         | 
| 145 145 | 
             
                """
         | 
| 146 146 |  | 
| 147 | 
            +
              Scenario: Getting Help with commands without description hidden
         | 
| 148 | 
            +
                Given the todo app is coded to hide commands without description
         | 
| 149 | 
            +
                When I successfully run `todo help`
         | 
| 150 | 
            +
                Then the output should contain:
         | 
| 151 | 
            +
                """
         | 
| 152 | 
            +
                NAME
         | 
| 153 | 
            +
                    todo - Manages tasks
         | 
| 154 | 
            +
             | 
| 155 | 
            +
                    A test program that has a sophisticated UI that can be used to exercise a
         | 
| 156 | 
            +
                    lot of GLI's power
         | 
| 157 | 
            +
             | 
| 158 | 
            +
                SYNOPSIS
         | 
| 159 | 
            +
                    todo [global options] command [command options] [arguments...]
         | 
| 160 | 
            +
             | 
| 161 | 
            +
                VERSION
         | 
| 162 | 
            +
                    0.0.1
         | 
| 163 | 
            +
             | 
| 164 | 
            +
                GLOBAL OPTIONS
         | 
| 165 | 
            +
                    --flag=arg         - (default: none)
         | 
| 166 | 
            +
                    --help             - Show this message
         | 
| 167 | 
            +
                    --[no-]otherswitch - 
         | 
| 168 | 
            +
                    --[no-]switch      - 
         | 
| 169 | 
            +
                    --version          - Display the program version
         | 
| 170 | 
            +
             | 
| 171 | 
            +
                COMMANDS
         | 
| 172 | 
            +
                    create, new - Create a new task or context
         | 
| 173 | 
            +
                    help        - Shows a list of commands or help for one command
         | 
| 174 | 
            +
                    initconfig  - Initialize the config file using current global options
         | 
| 175 | 
            +
                    list        - List things, such as tasks or contexts
         | 
| 176 | 
            +
                    ls          - LS things, such as tasks or contexts
         | 
| 177 | 
            +
                """
         | 
| 178 | 
            +
             | 
| 147 179 | 
             
              Scenario Outline: Getting Help for a top level command of todo
         | 
| 148 180 | 
             
                When I successfully run `todo <help_invocation>`
         | 
| 149 181 | 
             
                Then the output should contain:
         | 
    
        data/lib/gli/app.rb
    CHANGED
    
    | @@ -62,6 +62,17 @@ module GLI | |
| 62 62 | 
             
                  @program_long_desc
         | 
| 63 63 | 
             
                end
         | 
| 64 64 |  | 
| 65 | 
            +
                # Provide a flag to choose whether to hide or not from the help the undescribed commands.
         | 
| 66 | 
            +
                # By default the undescribed commands will be shown in the help.
         | 
| 67 | 
            +
                #
         | 
| 68 | 
            +
                # hide:: A Bool for hide the undescribed commands
         | 
| 69 | 
            +
                def hide_commands_without_desc(hide=nil)
         | 
| 70 | 
            +
                  unless hide.nil?
         | 
| 71 | 
            +
                    @hide_commands_without_desc = hide
         | 
| 72 | 
            +
                  end
         | 
| 73 | 
            +
                  @hide_commands_without_desc || false
         | 
| 74 | 
            +
                end
         | 
| 75 | 
            +
             | 
| 65 76 | 
             
                # Use this if the following command should not have the pre block executed.
         | 
| 66 77 | 
             
                # By default, the pre block is executed before each command and can result in
         | 
| 67 78 | 
             
                # aborting the call.  Using this will avoid that behavior for the following command
         | 
    
        data/lib/gli/command.rb
    CHANGED
    
    | @@ -44,6 +44,7 @@ module GLI | |
| 44 44 | 
             
                #           +skips_pre+:: if true, this command advertises that it doesn't want the pre block called first
         | 
| 45 45 | 
             
                #           +skips_post+:: if true, this command advertises that it doesn't want the post block called after it
         | 
| 46 46 | 
             
                #           +skips_around+:: if true, this command advertises that it doesn't want the around block called
         | 
| 47 | 
            +
                #           +hide_commands_without_desc+:: if true and there isn't a description the command is not going to be shown in the help
         | 
| 47 48 | 
             
                def initialize(options)
         | 
| 48 49 | 
             
                  super(options[:names],options[:description],options[:long_desc])
         | 
| 49 50 | 
             
                  @arguments_description = options[:arguments_name] || ''
         | 
| @@ -51,6 +52,7 @@ module GLI | |
| 51 52 | 
             
                  @skips_pre = options[:skips_pre]
         | 
| 52 53 | 
             
                  @skips_post = options[:skips_post]
         | 
| 53 54 | 
             
                  @skips_around = options[:skips_around]
         | 
| 55 | 
            +
                  @hide_commands_without_desc = options[:hide_commands_without_desc]
         | 
| 54 56 | 
             
                  @commands_declaration_order = []
         | 
| 55 57 | 
             
                  @flags_declaration_order = []
         | 
| 56 58 | 
             
                  @switches_declaration_order = []
         | 
    
        data/lib/gli/command_support.rb
    CHANGED
    
    | @@ -11,8 +11,9 @@ module GLI | |
| 11 11 | 
             
                end
         | 
| 12 12 |  | 
| 13 13 | 
             
                # Return true to avoid including this command in your help strings
         | 
| 14 | 
            +
                # Will honor the hide_commands_without_desc flag
         | 
| 14 15 | 
             
                def nodoc
         | 
| 15 | 
            -
                   | 
| 16 | 
            +
                  @hide_commands_without_desc and description.nil?
         | 
| 16 17 | 
             
                end
         | 
| 17 18 |  | 
| 18 19 | 
             
                # Return the arguments description
         | 
    
        data/lib/gli/dsl.rb
    CHANGED
    
    | @@ -53,7 +53,7 @@ module GLI | |
| 53 53 | 
             
                #           +:long_desc+:: the long_description, instead of using #long_desc
         | 
| 54 54 | 
             
                #           +:default_value+:: the default value, instead of using #default_value
         | 
| 55 55 | 
             
                #           +:arg_name+:: the arg name, instead of using #arg_name
         | 
| 56 | 
            -
                #           +:must_match+:: A regexp that the flag's value must match
         | 
| 56 | 
            +
                #           +:must_match+:: A regexp that the flag's value must match or an array of allowable values
         | 
| 57 57 | 
             
                #           +:type+:: A Class (or object you passed to GLI::App#accept) to trigger type coversion
         | 
| 58 58 | 
             
                #
         | 
| 59 59 | 
             
                # Example:
         | 
| @@ -156,6 +156,7 @@ module GLI | |
| 156 156 | 
             
                    :skips_pre => @skips_pre,
         | 
| 157 157 | 
             
                    :skips_post => @skips_post,
         | 
| 158 158 | 
             
                    :skips_around => @skips_around,
         | 
| 159 | 
            +
                    :hide_commands_without_desc => @hide_commands_without_desc,
         | 
| 159 160 | 
             
                  }
         | 
| 160 161 | 
             
                  @commands_declaration_order ||= []
         | 
| 161 162 | 
             
                  if names.first.kind_of? Hash
         | 
    
        data/lib/gli/version.rb
    CHANGED
    
    
    
        data/test/apps/todo/bin/todo
    CHANGED
    
    | @@ -17,6 +17,7 @@ end | |
| 17 17 | 
             
            sort_help (ENV['TODO_SORT_HELP'] || 'alpha').to_sym
         | 
| 18 18 | 
             
            wrap_help_text (ENV['TODO_WRAP_HELP_TEXT'] || 'to_terminal').to_sym
         | 
| 19 19 | 
             
            synopsis_format (ENV['SYNOPSES'] || 'full').to_sym
         | 
| 20 | 
            +
            hide_commands_without_desc ENV['HIDE_COMMANDS_WITHOUT_DESC'] === 'true'
         | 
| 20 21 |  | 
| 21 22 | 
             
            subcommand_option_handling :normal
         | 
| 22 23 |  | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: gli
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2. | 
| 4 | 
            +
              version: 2.10.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - David Copeland
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2014- | 
| 11 | 
            +
            date: 2014-04-22 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rake
         |