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

Issue 6588060: add --format=json style gnu args parsing (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 6 months ago by dave
Modified:
11 years, 6 months ago
Reviewers:
mp+127419, rog
Visibility:
Public.

Description

add --format=json style gnu args parsing https://code.launchpad.net/~dave-cheney/gnuflag/001-parse-more-gnu-args/+merge/127419 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 3

Patch Set 2 : add --format=json style gnu args parsing #

Unified diffs Side-by-side diffs Delta from patch set Stats (+14 lines, -4 lines) Patch
A [revision details] View 1 1 chunk +2 lines, -0 lines 0 comments Download
M flag.go View 2 chunks +6 lines, -2 lines 0 comments Download
M flag_test.go View 1 3 chunks +6 lines, -2 lines 0 comments Download

Messages

Total messages: 5
dave_cheney.net
Please take a look.
11 years, 6 months ago (2012-10-02 06:43:49 UTC) #1
dave_cheney.net
Please take a look.
11 years, 6 months ago (2012-10-02 06:57:28 UTC) #2
rog
thanks for working on this - it needed doing! a few thoughts below. https://codereview.appspot.com/6588060/diff/1/flag.go File ...
11 years, 6 months ago (2012-10-02 07:10:01 UTC) #3
dave_cheney.net
Thank you for your comments. I have a slight worry about scope creep, we only ...
11 years, 6 months ago (2012-10-02 11:15:32 UTC) #4
rog
11 years, 6 months ago (2012-10-02 13:01:58 UTC) #5
See alternative CL at https://codereview.appspot.com/6598052/

On 2 October 2012 12:15,  <dave@cheney.net> wrote:
> Thank you for your comments. I have a slight worry about scope creep, we
> only have to support --format=json to fix the current bug in juju.
>
>
>
> https://codereview.appspot.com/6588060/diff/1/flag.go
> File flag.go (right):
>
> https://codereview.appspot.com/6588060/diff/1/flag.go#newcode729
> flag.go:729: if len(v) > 1 && len(v[1]) > 0 {
> On 2012/10/02 07:10:01, rog wrote:
>>
>> this seems a bit odd to me. i think it's perfectly ok to have an empty
>
> *value*,
>>
>> but an empty flag is wrong.
>
>
>> i think we need to return an error here if there's an empty flag.  if
>
> we store
>>
>> the entire string following the flag (including the leading '=')
>
> inside
>>
>> f.procFlag, then parseGnuFlagArg can know that it's got that style of
>
> flag, and
>>
>> process accordingly.
>
>
>> that way we allow the following cases:
>> --foo=false
>
>
> yup, will fix.
>
>> -x=true
>
>
> I don't think this is valid gnuarg

Hmm, that's a good point. I should disallow = for single-letter flags.

>> --bar=
>
>
>> but not
>> --=x
>
>
> good point, this has no name.
>
>
>> i think -= should probably be an error too.
>
>
> I think it is an error in the same way -x=true is an error

actually, -x=true is not necessarily an error with GNU flag parsing - it
specifies that -x has the argument "=true".

-=true is always an error though, as is -=.
Sign in to reply to this message.

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