Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2)

Issue 6107048: Rearrange Parse/ParsePositional responsibilities

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 11 months ago by fwereade
Modified:
12 years, 11 months ago
Reviewers:
mp+103064, niemeyer
Visibility:
Public.

Description

Rearrange Parse/ParsePositional responsibilities ...in order to support forthcoming extraction of SuperCommand's command-selection capability. Also: * renamed ParsePositional to Consume, which IMO fits better * moved CheckEmpty into embeddable FlagCommand type, which implies no positional arguments https://code.launchpad.net/~fwereade/juju/go-recurse-parse-directly/+merge/103064 Requires: https://code.launchpad.net/~fwereade/juju/go-add-cmd-context/+merge/96131 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 18
Unified diffs Side-by-side diffs Delta from patch set Stats (+59 lines, -58 lines) Patch
A [revision details] View 1 chunk +2 lines, -0 lines 0 comments Download
M cmd/command.go View 2 chunks +19 lines, -8 lines 5 comments Download
M cmd/context_test.go View 2 chunks +1 line, -4 lines 2 comments Download
M cmd/juju/bootstrap.go View 2 chunks +1 line, -6 lines 2 comments Download
M cmd/jujud/agent.go View 3 chunks +5 lines, -4 lines 4 comments Download
M cmd/jujud/flag.go View 1 chunk +2 lines, -2 lines 0 comments Download
M cmd/jujud/initzk.go View 3 chunks +5 lines, -4 lines 4 comments Download
M cmd/jujud/machine.go View 1 chunk +5 lines, -5 lines 0 comments Download
M cmd/jujud/unit.go View 1 chunk +5 lines, -5 lines 0 comments Download
M cmd/supercommand.go View 3 chunks +12 lines, -12 lines 1 comment Download
M cmd/supercommand_test.go View 3 chunks +2 lines, -8 lines 0 comments Download

Messages

Total messages: 7
fwereade
Please take a look.
12 years, 11 months ago (2012-04-23 09:23:46 UTC) #1
niemeyer
I think this is almost ready to go except for a few suggestions. I'd like ...
12 years, 11 months ago (2012-04-24 00:11:39 UTC) #2
fwereade
[this may all become moot in the context of the discussion in play on https://codereview.appspot.com/6100050/ ...
12 years, 11 months ago (2012-04-24 08:41:25 UTC) #3
fwereade
On 2012/04/24 08:41:25, fwereade wrote: > So, suggestion: ParsePositional/Consume will (1) take a new name ...
12 years, 11 months ago (2012-04-24 08:53:21 UTC) #4
fwereade
On 2012/04/24 08:53:21, fwereade wrote: > ...but I can imagine rational beings hating the fact ...
12 years, 11 months ago (2012-04-24 09:20:53 UTC) #5
fwereade
Hmm. func Reduce(args []string) (Command, []string, error) ... c, args, err = c.Reduce(f.Args()) ...perhaps?
12 years, 11 months ago (2012-04-24 10:31:26 UTC) #6
fwereade
12 years, 11 months ago (2012-04-24 10:46:25 UTC) #7
(awaiting discussion re reparsing; other points addressed)

https://codereview.appspot.com/6107048/diff/1/cmd/command.go
File cmd/command.go (right):

https://codereview.appspot.com/6107048/diff/1/cmd/command.go#newcode109
cmd/command.go:109: type FlagCommand struct{}
On 2012/04/24 00:11:39, niemeyer wrote:
> I suggest organizing it like this:
> 
> func ConsumeZeroArgs(args []string) ([]string, error) {
> 	if len(args) != 0 {
> 		return fmt.Errorf("unrecognised args: %s", args)
> 	}
> 	return nil, nil
> )
> 
> type ZeroArgsConsumer struct{}
> 
> func (ZeroArgsConsumer) Consume(args []string) ([]string, error) {
> 	return ConsumeZeroArgs(args)
> }

Nice. Done.

https://codereview.appspot.com/6107048/diff/1/cmd/context_test.go
File cmd/context_test.go (right):

https://codereview.appspot.com/6107048/diff/1/cmd/context_test.go#newcode24
cmd/context_test.go:24: *cmd.FlagCommand
On 2012/04/24 00:11:39, niemeyer wrote:
> s/*//; it's a pointer to no data.. we may as well not have a pointer. 

Done.

https://codereview.appspot.com/6107048/diff/1/cmd/juju/bootstrap.go
File cmd/juju/bootstrap.go (right):

https://codereview.appspot.com/6107048/diff/1/cmd/juju/bootstrap.go#newcode12
cmd/juju/bootstrap.go:12: *cmd.FlagCommand
On 2012/04/24 00:11:39, niemeyer wrote:
> Ditto.

Done.

https://codereview.appspot.com/6107048/diff/1/cmd/jujud/agent.go
File cmd/jujud/agent.go (right):

https://codereview.appspot.com/6107048/diff/1/cmd/jujud/agent.go#newcode14
cmd/jujud/agent.go:14: *cmd.FlagCommand
On 2012/04/24 00:11:39, niemeyer wrote:
> No need to have this here.

Done.

https://codereview.appspot.com/6107048/diff/1/cmd/jujud/agent.go#newcode50
cmd/jujud/agent.go:50: return c.FlagCommand.Consume(args)
On 2012/04/24 00:11:39, niemeyer wrote:
> return ConsumeZeroArgs(args)

Done.

https://codereview.appspot.com/6107048/diff/1/cmd/jujud/initzk.go
File cmd/jujud/initzk.go (right):

https://codereview.appspot.com/6107048/diff/1/cmd/jujud/initzk.go#newcode11
cmd/jujud/initzk.go:11: *cmd.FlagCommand
On 2012/04/24 00:11:39, niemeyer wrote:
> Also not necessary.

Done.

https://codereview.appspot.com/6107048/diff/1/cmd/jujud/initzk.go#newcode46
cmd/jujud/initzk.go:46: return c.FlagCommand.Consume(args)
On 2012/04/24 00:11:39, niemeyer wrote:
> return ConsumeZeroArgs(args)

Done.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b