pulumi / pulumi-command

Apache License 2.0
61 stars 25 forks source link

Command should use []string not string #45

Open ghostsquad opened 2 years ago

ghostsquad commented 2 years ago

Hello!

Issue details

Using string instead of []string for command means that the user must handle separating args, handling quoting issues, etc.

func CommandContext(ctx Context, name string, arg ...string)

I believe that a better user experience would be to allow the user to provide an array of args as well.

ghostsquad commented 2 years ago

I think this is valuable, but it appears that native support for arg ...string doesn't exist for the Session in the ssh package. I asked around in the Gopher slack server, and no one had a better idea, other than to essentially not use the ssh package natively, and instead always use os.Exec and call ssh from there, which doesn't feel much better.

ghostsquad commented 2 years ago

Maybe the right way to handle this would be to accept args []string and shellquote each arg, then join(" ", quotedArgs)?

I guess I'd have to write some tests.

https://github.com/frioux/leatherman/tree/main/pkg/shellquote

guineveresaenger commented 2 years ago

@pgavlin might have more insight here - we certainly welcome code changes but I want to make sure you're aligned in direction. <3