Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new shorthand parser for nested maps #1444

Merged
merged 9 commits into from
Aug 19, 2015
Merged

Conversation

jamesls
Copy link
Member

@jamesls jamesls commented Aug 11, 2015

This adds a new shorthand parser that can handle nested maps via a {foo=bar} syntax. Note this is not plumbed into the argprocess module yet, it's entirely standalone in this PR.

The plan for this is:

  1. Get this parser reviewed
  2. Integrate this with the existing shorthand parser and add in back-compat code (separate PR).

There's one point in this PR not implemented that we need to decide. Right now, the explicit list parser [foo, bar baz] assumes that all the values are strings. If we want to support nested lists or lists of hashes, we will need to require string values that start with [ and { to be quoted. There's a comment on line 148 that explains this.

cc @kyleknap @mtdowling @rayluo

This adds a proper parser to the shorthand parser.
The parser still maintains the quirky of the old
parser where possible to maintain backwards compatibility.
@jamesls jamesls added the pr:needs-review This PR needs a review from a Member. label Aug 13, 2015
"Expected: '%s', received: '%s' for input:\n"
"%s\n"
"%s\n"
) % (self.expected, self.actual, self.value,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like the idea of the '^' pointer. It could be super useful for debugging. How well does it look if the self.value requires more than two lines on the terminal due to wrapping in the terminal? Will the '^' still match up with where the syntax error occurred? I am not sure if I can think of any better representation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe it handles that case. I can update that.

@kyleknap
Copy link
Contributor

The changes look fine. I have just a couple of questions that probably would got have answered with the subsequent PR's that you are sending.

else:
return self._csv_list()

def _csv_list(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method does a lot, including backtracking the parser. It would be nice for maintainability reasons to have a comment here explaining how it works.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@jamesls
Copy link
Member Author

jamesls commented Aug 18, 2015

I believe I've incorporated all the feedback here. cc @kyleknap @mtdowling

Let me know if I missed anything.

@kyleknap
Copy link
Contributor

Looks good. Thanks for updating. 🚢

@jamesls jamesls merged commit 0e292bd into aws:develop Aug 19, 2015
thoward-godaddy pushed a commit to thoward-godaddy/aws-cli that referenced this pull request Feb 12, 2022
* feat(perf): Improve load time of help text

* update docker version in isolated.txt file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants