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

[RFE] Better params ergonomics #58

Open
Fryguy opened this issue Feb 1, 2021 · 1 comment
Open

[RFE] Better params ergonomics #58

Fryguy opened this issue Feb 1, 2021 · 1 comment

Comments

@Fryguy
Copy link
Member

Fryguy commented Feb 1, 2021

A typical command is currently:

AwesomeSpawn.run!("ls", :params => [:a, :l])

Most times, params are needed (because sanitizing them is the point of using AwesomeSpawn, otherwise you'd probably just use backticks). But that params key is clunky.

Additionally, the params key is not passed to AwesomeSpawn.build_command_line

AwesomeSpawn.build_command_line("ls", [:a, :l])
# => "ls -a -l"

As such, I propose we drop the params key altogether, and make it part of the "command" portion via Array or Hash. So, I could see one or all of

AwesomeSpawn.run!("ls" => [:a, :l])
AwesomeSpawn.run!(["ls", [:a, :l]])
AwesomeSpawn.run!("ls", [:a, :l])

I kind of like the first one, and the second one is just an associative array version of the first (i.e. it's the same as .to_a), so it's straightfoward to implement.

Then, we should make build_command_line have the exact same interface.

@chessbyte
Copy link
Member

first variant looks very readable and intuitive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants