Giter VIP home page Giter VIP logo

Comments (21)

josevalim avatar josevalim commented on August 26, 2024

It should work. If not, try passing a switch: "no-doc-type" => :boolean. A patch is welcome!

from thor.

ccbcreg avatar ccbcreg commented on August 26, 2024

This "version-control" => :boolean, :version_control => :boolean and "version_control" => :boolean worked. However, you must call on the command line as --version-control not --version_control, it appears (have not looked yet) that the option parser is are looking for underscores. I can change my API to use hyphens.

Is this worth noting in the documentation? Let me know if you want to task me with this.

Thank you for the help, much appreciated.

from thor.

josevalim avatar josevalim commented on August 26, 2024

It should actually be fixed. But I think that --version-control is way better than --version_control. More consistent with all others command lines apps. :)

from thor.

ccbcreg avatar ccbcreg commented on August 26, 2024

Agreed. Thanks again.

from thor.

josevalim avatar josevalim commented on August 26, 2024

Patch please?

from thor.

ccbcreg avatar ccbcreg commented on August 26, 2024

Forking now...

from thor.

ccbcreg avatar ccbcreg commented on August 26, 2024

Here is my first crack, tests included.

Patch:
http://gist.github.com/584931

from thor.

ccbcreg avatar ccbcreg commented on August 26, 2024

Also:
Branch:
http://github.com/ccbcreg/thor/tree/enable_underscores

Commit:
http://github.com/ccbcreg/thor/commit/838428e51c5def3e025787af6cad6b7e47234c1a

from thor.

ccbcreg avatar ccbcreg commented on August 26, 2024

Any word on this?

from thor.

josevalim avatar josevalim commented on August 26, 2024

Sorry, but now that I see the patch, I don't agree with it. Typing --version-control is more convenient than --version_control and it more inline with most binaries out there. If you want to use --version_control, I believe you need to explicitly give it as the option name (instead of just :version_control).

from thor.

ccbcreg avatar ccbcreg commented on August 26, 2024

Understood, the patch was merely to make the older apps written with thor 0.9.9 work with the current version. I'll give your suggestion a try. Thank you.

from thor.

ccbcreg avatar ccbcreg commented on August 26, 2024

Just tried your suggestion:

method_options :name => :required, :repos => :optional, "--version_control" => :boolean, :no_doc_type => :boolean, :no_pdf => :boolean, :unabridged => :boolean

It appears to not work. I will update my older thor applications args to use hypens going forward. Thanks again for the consideration.

from thor.

josevalim avatar josevalim commented on August 26, 2024

The string version is supposed to work. If you want to provide a patch for this case, I will gladly accept it!

from thor.

ccbcreg avatar ccbcreg commented on August 26, 2024

You know I thought about it more this morning and I think I need to mention this one more time.

The patch above is a bug fix to make the current version of thor backwards compatible with older code--it is not specific to my needs or my conventions. Since all command line arguments now must be explicitly dasherized, any older code that uses underscores anywhere will now break. The above patch fixes this problem.

My instance is that I have command line tools that are called via Capistrano and would have to change how they are called. eg

namespace :pancake do
  desc "Pancake the product"
  task :default do
    system("pancake download_product --name=#{application} --version_control")
  end
end

The above code works with thor 0.9.9, when I upgrade to the current version it does not and was the source of serious problems and wasted time debugging. This patch fixes this bug without removing or changing any functionality and passes all the existing test. Please reconsider this patch.

from thor.

josevalim avatar josevalim commented on August 26, 2024

Sorry, but this should have been caught earlier. Because if we apply your patch now, we are going to break all new command lines that relies on this current behavior. Break the old ones or preserve the new ones? I choose the second as we are on 0.14.x.

from thor.

ccbcreg avatar ccbcreg commented on August 26, 2024

This will not break the current behavior. It still passes all the tests. The patch only convert args like --version_control to --version-control. This only effects args with underscores, which currently do not work, this will convert underscored args to dasherize to adhere to the current behavior.

from thor.

josevalim avatar josevalim commented on August 26, 2024

Let me get this straight:

method_option :foo_bar

Should be given as:

thor something --foo-bar=baz

And this works today. What your patch does is to allow:

thor something --foo_bar=baz

To also work?

from thor.

ccbcreg avatar ccbcreg commented on August 26, 2024

Yes, exactly.

from thor.

josevalim avatar josevalim commented on August 26, 2024

Ok, sorry for the confusion. I am applying it.

from thor.

ccbcreg avatar ccbcreg commented on August 26, 2024

Excellent! Thank you.

from thor.

josevalim avatar josevalim commented on August 26, 2024

Applied, thanks for your patience!

from thor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.