tedsmitt / ecsgo

Provides an interactive prompt to connect to ECS Containers using the ECS ExecuteCommand API.
Apache License 2.0
81 stars 13 forks source link

Option to ignore "fluff" when using the `--cmd` flag #37

Closed hsommerlandreason closed 8 months ago

hsommerlandreason commented 10 months ago

It would be very nice to have the opportunity to ignore printing the additional information when using the --cmd flag in order to make piping easier.

As of now if i run: ecsgo -n xxxxxxxxxx -t xxxxxxx -u xxxxx -c 'echo "hello"' > testsson.txt

testsson.txt will contain all of this.

Cluster: xxxxxx | Service:  | Task: xxxxxxxxxxxx | Cmd: echo "hello"
Connecting to container xxxxxxxxxxxxx

Starting session with SessionId: ecs-execute-command-xxxxxxxxxxxxxx
hello

Exiting session with sessionId: ecs-execute-command-xxxxxxxxx.

It would be very convenient not to have to strip the excess info manually.

tedsmitt commented 8 months ago

I think the best I can do is remove the first few lines i.e.

Cluster: xxxxxx | Service:  | Task: xxxxxxxxxxxx | Cmd: echo "hello"
Connecting to container xxxxxxxxxxxxx

Since the remaining Starting session with SessionId... is printed from the session-manager-plugin. It might be troublesome to remove that text. It looks like there is an open issue for this on the session-manager-plugin repo though.

Would you be happy for me to add a -q flag to disable the aforementioned lines? Something like

ecsgo -q -n test-ecsgo -t  584c7724322e4d41a4d560523aacc745 -u nginx -c 'echo hello'

Starting session with SessionId: ecs-execute-command-0eb8eff6298eef532
hello

Exiting session with sessionId: ecs-execute-command-0eb8eff6298eef532.
tedsmitt commented 8 months ago

@hsommerlandreason added a --quiet flag in v0.5.0, this is probably the best we can do until https://github.com/aws/session-manager-plugin/issues/85 is addressed.