donnemartin / saws

A supercharged AWS command line interface (CLI).
Other
5.24k stars 281 forks source link

Using grep on ls with args doesn't work #35

Closed mlimaloureiro closed 8 years ago

mlimaloureiro commented 8 years ago

Using the ls without args works but in this cases it doesn't, for instance

saws> aws ec2 ls --ec2-tag-value somevalue | grep IpAddress
usage: grep [-abcDEFGHhIiJLlmnOoqRSsUVvwxZ] [-A num] [-B num] [-C[num]]
    [-e pattern] [-f file] [--binary-files=value] [--color=when]
    [--context[=num]] [--directories=action] [--label] [--line-buffered]
    [--null] [pattern] [file ...]

Error parsing parameter '--filters': Expected: '=', received: 'EOF' for input:
somevalue
donnemartin commented 8 years ago

@mlimaloureiro: Thanks for the bug report, I'll take a closer look tomorrow.

donnemartin commented 8 years ago

@mlimaloureiro: Took a quick look, logging some info here, in case you want to try to fix it :)

There seems to be a problem with replace_substitution and/or replace_shortcut.

In process_command if you change print('') to print(text) you'll see the incorrect command that's throwing off awscli.

mlimaloureiro commented 8 years ago

thx @donnemartin found the problem going to try to fix it tomorrow.

the problem is here https://github.com/donnemartin/saws/blob/master/saws/completer.py#L142

since the text that the function is receiving is this

aws ec2 ls --ec2-tag-value ap-prod1 | grep IpAddress

and the function assumes the last token to be the next value after %s it results in this

aws ec2 describe-instances --filters "Name=tag-value,Values=IpAddress" ap-prod1 | grep
donnemartin commented 8 years ago

:+1:

mlimaloureiro commented 8 years ago

https://github.com/donnemartin/saws/pull/45

donnemartin commented 8 years ago

Fixed with e06eaba4a869cd09758ba7b0663d868fb541dd22.