code review 3071041: flag: handle multiple calls to flag.Parse (issue3071041)

840 views
Skip to first unread message

r...@golang.org

unread,
Dec 6, 2010, 2:22:32 PM12/6/10
to golan...@googlegroups.com, re...@codereview.appspotmail.com
Reviewers: golang-dev_googlegroups.com,

Message:
Hello golan...@googlegroups.com,

I'd like you to review this change.


Description:
flag: handle multiple calls to flag.Parse

Please review this at http://codereview.appspot.com/3071041/

Affected files:
M src/pkg/flag/flag.go


r...@google.com

unread,
Dec 6, 2010, 2:27:47 PM12/6/10
to r...@golang.org, r...@golang.org, golan...@googlegroups.com, re...@codereview.appspotmail.com
R=r

This change keeps flag.Parse from crashing if called multiple times.
It also lets one do things like

flag.Parse()
switch flag.Arg(0) {
case "cmd1":
... add more flags
case "cmd2":
... add more flags
}
os.Args = flag.Args()
flag.Parse()

to implement the common subcommand
command line parsing found in tools like
Mercurial. I'm not sure if that's a good thing,
but not crashing certainly is.

http://codereview.appspot.com/3071041/

r...@golang.org

unread,
Dec 6, 2010, 2:33:09 PM12/6/10
to r...@golang.org, golan...@googlegroups.com, re...@codereview.appspotmail.com
looks good but wants a test if feasible and maybe a sentence of new
package documentation

http://codereview.appspot.com/3071041/

r...@golang.org

unread,
Dec 7, 2010, 11:50:09 AM12/7/10
to r...@golang.org, golan...@googlegroups.com, re...@codereview.appspotmail.com

r...@golang.org

unread,
Dec 7, 2010, 11:57:19 AM12/7/10
to r...@golang.org, golan...@googlegroups.com, re...@codereview.appspotmail.com

r...@golang.org

unread,
Dec 7, 2010, 1:19:03 PM12/7/10
to r...@golang.org, r...@golang.org, golan...@googlegroups.com, re...@codereview.appspotmail.com
*** Submitted as cc69ceb37529 ***

flag: handle multiple calls to flag.Parse

R=r
CC=golang-dev
http://codereview.appspot.com/3071041


http://codereview.appspot.com/3071041/

Reply all
Reply to author
Forward
0 new messages