ManageIQ / ManageIQ/awesome_spawn

[RFE] Better params ergonomics

Open
#58 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
Ruby
Stars
9
Forks
14
PR merge metrics
No merged PRs in 30d

Description

A typical command is currently:

```ruby
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

```ruby
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

```ruby
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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the existing interfaces for AwesomeSpawn.run! and AwesomeSpawn.build_command_line, including how the current params option is handled. Resolve which command/params form is supported and make both entry points share it, with command construction and parameter passing behaving consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.