[Rubygems-developers] Suggestions regarding new CLI

Jim Weirich jim at weirichhouse.org
Fri Jun 25 02:24:01 EDT 2004

Jim Weirich wrote:
> Its hard to say.  If you run all the tests individually, they will all 
> pass.  Its only when two of the tests are run together in the same 
> session do you get the failing test.  That implies some interaction 
> between the tests, which is not good.  My feeling was that it has 
> something to do with the singleton nature of the CommandManager, which 
> is why I would like to break the class into something a bit smaller and 
> work with it.  Perhaps I should focus on the singleton aspect first.

A very productive evening.  The failing unit test was caused by 
interference between two tests working on the singleton instance of the 
command manager.

I changed the command manager to install all the commands into every 
instance, not just the one referenced by the instance command.  That 
allowed the tests to be written using CommandManager.new (rather than 
CommandManager.instance).  No more interference and all the tests are 
passing again.

After that I really went to town and cleaned up the CommandManager.  The 
  gem commands are now all together in a separate file 
(gem_commands.rb).  Its easy to add new commands.  I added the 
rubygems-info command back into the mix.  Added a version command.  And 
added "list" as an alias for "query".

Commands may now be abbreviated (as long as they are unique).

    gem i    --> gem install
    gem u    --> error: ambiguous command (uninstall, update)

Gem install now takes the gem name as an argument instead of an option. 

    gem install rake

rather than

    gem install --name rake

Oh, and "gem2" is gone.  I promoted it to be the standard "gem" script 
now.  Let me know if anyone has problems.

Still to do:
* Do the argument thing on other commands.
* Clean up the help messages.

-- Jim Weirich    jim at weirichhouse.org     http://onestepback.org
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

More information about the Rubygems-developers mailing list