Skip to content

Commit

Permalink
Merge pull request #830 from danielgtaylor/shorthand-list-fix
Browse files Browse the repository at this point in the history
Fix single item shorthand list parsing bug. Fixes #830.
  • Loading branch information
danielgtaylor committed Jun 30, 2014
2 parents c2580e0 + db9538b commit ba218c4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ CHANGELOG
Next Release (TBD)
==================

* bugfix:Shorthand JSON: Fix bug where shorthand lists with
a single item (e.g. ``--arg Param=[item]``) were not parsed
correctly.
(`issue 830 <https://github.com/aws/aws-cli/pull/830>`__)
* bugfix:``aws cloudsearchdomain``: Fix bug where
``--endpoint-url`` is required even for ``help`` subcommands
(`issue 828 <https://github.com/aws/aws-cli/pull/828>`__)
Expand Down
6 changes: 5 additions & 1 deletion awscli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ def _split_with_quotes(value):
if list_start >= 0 and value.find(']') != -1 and \
(quote_char is None or part.find(quote_char) > list_start):
# This is a list, eat all the items until the end
new_chunk = _eat_items(value, iter_parts, part, ']')
if ']' in part:
# Short circuit for only one item
new_chunk = part
else:
new_chunk = _eat_items(value, iter_parts, part, ']')
list_items = _split_with_quotes(new_chunk[list_start + 2:-1])
new_chunk = new_chunk[:list_start + 1] + ','.join(list_items)
new_parts.append(new_chunk)
Expand Down
10 changes: 8 additions & 2 deletions tests/unit/test_argprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,18 @@ def test_list_structure_list_scalar_3(self):
{"Name": "foo",
"Args": ["a", "k1=v1", "b"]},
{"Name": "bar",
"Args": ["baz"]}
"Args": ["baz"]},
{"Name": "single_kv",
"Args": ["key=value"]},
{"Name": "single_v",
"Args": ["value"]}
]

simplified = self.simplify(p, [
"Name=foo,Args=[a,k1=v1,b]",
"Name=bar,Args=baz"
"Name=bar,Args=baz",
"Name=single_kv,Args=[key=value]",
"Name=single_v,Args=[value]"
])

self.assertEqual(simplified, expected)
Expand Down

0 comments on commit ba218c4

Please sign in to comment.