[Rubygems-developers] My weekend work

Jim Weirich jim at weirichhouse.org
Sun Jul 4 17:22:15 EDT 2004

Gavin Sinclair wrote:
> Hi folks,
> Here's the changes I've made, in line with my message to the list
> ("Suggestions regarding the new CLI") on 20 June.
> * Improved (subjective, of course) the general 'help' message.
> * Improved the output of 'gem help COMMAND'.
> * Explicitly handle 'gem -h/--help' and 'gem -v/--version'.
> * No longer allow 'gem --commands' and 'gem --examples'. [1]

All good!

> * Consolidated boolean commands with their negatives, e.g. --test and
>   --no-test become --[no-]test.

Cool.  I didn't know you could do this.  This becomes important when we 
have config files and you need both an --option and --no-option to 
override defaults in the config.

> * Refactored the options that 'install' and 'update' have in common.
> * Renamed --gen-rdoc to --rdoc.

More goodness.

> * Made 'list' and 'search' full-blooded commands. [2]

I'm a bit concerned that with list/search/query it is hard to 
know/remember the subtle differences between them.  I like the 
functionality, but we might want to think about the command structure.

> [1] I kind of like these commands, but dislike the proliferation of
>     ways of accessing help.  Comments sought.

The basic "gem help" is clear and maps out how the user can get more 
help.  I do like the new text.

> NOTE!  One unit test is failing because of my changes.  I don't know
> how to change that test appropriately.

The Mock UI code throws a MockGemUi::TermError when one of the 
termination methods is called.  This is because the tests were missing 
the fact that several of the commands were terminating the program.  By 
having the mock ui throw an exception, I'm guaranteed that the unit test 
is aware of the termination.

So, I changed the test to catch MockGemUi::TermError and then asserted 
that standard out (ui.error) had the error code.

The important thing is that we are consistent.  When I started 
refactoring the code, some exceptions were propagated, some were handled 
and continued, some were handled with program termination.  I changed 
the code so that ALL exceptions that couldn't be handled locally were 
propagated to the top level and handled consistently there.  If we start 
catching bad option exceptions, lets make sure we get them all and treat 
them the same.

BTW, I noticed that I missed some changes I though made it in the code 
base.  I'll probably add those tonight.  I'm going to be out of town and 
out of touch for a few days.  I'll check back later this week.

-- 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