[darcs-users] darcs patch: Simplify some of my own code. (and 1 more)
Eric Kow
kowey at darcs.net
Sat Jan 17 13:56:35 UTC 2009
On Sat, Jan 17, 2009 at 19:42:17 +1100, Trent W.Buck wrote:
> Improved version of some stuff I sent yesterday.
>
> Sat Jan 17 12:55:05 EST 2009 Trent W. Buck <trentbuck at gmail.com>
> * Simplify some of my own code.
>
> Sat Jan 17 19:15:33 EST 2009 Trent W. Buck <trentbuck at gmail.com>
> * Refactor initial argument dispatcher.
Applied, thanks! Comment below
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.
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
Oops :-) I think both of us were mentally filtering the command out of
argv.
--
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://lists.osuosl.org/pipermail/darcs-users/attachments/20090117/07eaabad/attachment.pgp
More information about the darcs-users
mailing list