On Sat, Jan 17, 2009 at 01:56:35PM +0000, Eric Kow wrote:
> Refactor initial argument dispatcher.
> -------------------------------------
> > +  argv <- getArgs
> > +  case argv of
> > +    -- User called "darcs" without arguments.
> > +    []                  -> print_version >> help_cmd [] []
> > +    -- User called "darcs --foo" for some special foo.
> > +    ["-h"]              -> help_cmd [] []
> > +    ["--help"]          -> help_cmd [] []
> > +    ["--overview"]      -> help_cmd [Verbose] []
> > +    ["--commands"]      -> list_available_commands
> > +    ["-v"]              -> putStrLn darcs_version
> > +    ["--version"]       -> putStrLn darcs_version
> > +    ["--exact-version"] -> do
> > +              putStrLn $ "darcs compiled on "++__DATE__++", at "++__TIME__
> > +              putStrLn context
> 
> Much nicer! Thanks for having the courage to risk a little code
> duplication for extra readability.

Only because I couldn't work out how to make it concise without the
duplication :-)

> Also, I think I understand now what was buggy in the previous
> edition of the patch (probably not news to you, as this version
> avoids the error): it made it so that a command line with only
> argument exists immediately, which is not what you want if your
> one argument is a command, e.g. darcs whatsnew

BTW, you'll note that I don't call exitWith explicitly anymore,
because the subcommand case is now in _ -> ..., rather than falling
through.  I forgot to confirm that this still results in e.g. "darcs
--version" always returning a successful exit status.

PS: I forgot to add FIXME: why do we use both print_version and
    putStrLn darcs_version?  They emit slightly different output,
    which is why I didn't "fix" it in this refactor patch.
_______________________________________________
darcs-users mailing list
[email protected]
http://lists.osuosl.org/mailman/listinfo/darcs-users

Reply via email to