Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Support version flag only for the root command #13

Closed
fabiopelosin opened this Issue · 14 comments

2 participants

@fabiopelosin
Owner
$ pod --version
0.32.1

$ pod search --version
[!] Unknown arguments: --version

Via @AliSoftware: CocoaPods/CocoaPods#2094

@alloy
Owner

But CLAide doesn’t do anything with --version. If and how you implement it depends on the program that uses CLAide.

@alloy
Owner

(In this case ‘the program’ being CocoaPods.)

@fabiopelosin
Owner

Every program should be versioned, so I think that CLAide should take care of it like it does for the plugins.

@alloy
Owner

How would it do that? We cannot assume where a version constant is defined, if any.

@fabiopelosin
Owner

Add the writable CLAide::Command#version attribute. Similar to CLAide::Command#command

@fabiopelosin
Owner

For the plugins the version would be asked to RubyGems directly.

@alloy
Owner

Ok, I have an idea, a CLAide::Command could have a #version method, which, if defined on a command class, makes it available as an option. The program can then implement the method to return the version from wherever they keep it.

To be clear, it’s important that CLAide::Command only uses a #version method if it’s defined on this exact class, not one of its superclasses. Otherwise we still end-up with a --version option on each command.

@alloy
Owner

Add the writable CLAide::Command#version attribute. Similar to CLAide::Command#command

For the plugins the version would be asked to RubyGems directly.

While that would probably work for the program’s own version (a constant would already be available), I don’t like the idea of asking RubyGems for this if the info might not be needed at all, which is why we need a method that can be queried when really needed.

@alloy
Owner

(I don’t like asking for it if not needed because I want to keep the CLI stuff as fast as possible.)

@fabiopelosin
Owner

I mean asking using Gem::latest_version_for which is the similar to the mechanism used to load the plugins in first place and would be use only in --version --verbose.

@fabiopelosin
Owner

The program version would be passed as a constant at the load time of the class and should have a non noticeable performance impact.

@alloy
Owner

Ah I see what you mean now, I thought the user would have to query and set the gem versions themselves, which being at the class-level would mean that that penalty was always incurred.

Ok, so if CLAide queries this automatically for a command class that has plugins enabled and the Command::version attribute is set, then that should work nicely indeed.

@fabiopelosin
Owner

Ace :+1:

@fabiopelosin
Owner

Closed by fbbb2a3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.