Skip to content

Allow option to have multiple comma separated values#624

Merged
WesCossick merged 7 commits intosparksuite:masterfrom
Peter-Sparksuite:master
Apr 13, 2026
Merged

Allow option to have multiple comma separated values#624
WesCossick merged 7 commits intosparksuite:masterfrom
Peter-Sparksuite:master

Conversation

@Peter-Sparksuite
Copy link
Copy Markdown
Contributor

@Peter-Sparksuite Peter-Sparksuite commented Apr 9, 2026

Closes #623

Currently, when multiple valid options are provided as separate pairs of option + value, only the first option value is presented to the application.

eg:

--optionName value1 --optionName value2

only value1 will be present within input.options.optionName string array.

This change allows the following:

--optionName value1,value2

and for the application to see both values within input.options.optionName (which is a string array)

If one of the values are not valid, it will be called out as such.

I've also included a test variant that specifically validates that the multi-value behavior is functioning as expected.

@Peter-Sparksuite
Copy link
Copy Markdown
Contributor Author

@WesCossick please take a look at this.

@WesCossick WesCossick added the bug label Apr 10, 2026
Comment thread src/utils/get-organized-arguments.ts Outdated
@WesCossick
Copy link
Copy Markdown
Member

When an option has acceptsMultiple: true, how does that impact the --help output? Just want to make sure it's clear we expect comma-separated values (e.g., --toppings=cheese,bacon instead of multiple options (e.g., --toppings=cheese --toppings=bacon).

Co-authored-by: Wes Cossick <WesCossick@users.noreply.github.com>
Comment on lines 13 to 21
// Define what organized arguments look like
interface OrganizedArguments {
command: string;
data?: string | number | string[] | number[];
flags: string[];
options: string[];
values: (string | number)[];
passThrough?: string[];
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this file, data (which also offers an acceptsMultiple option) can either be a single value or an array. But for values, we're keeping it as a comma-separated value until the src/utils/construct-input-object.ts file. That seems a bit inconsistent. Should the src/utils/get-organized-arguments.ts be storing the values as an array?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, in some places, the array (eg: flags, options) are used as an indexed array, the index being determined by the position of the flag or option in the list of supported flags or options. In other cases, it's actually the same list that ends up in the object that's handed back to the application.

My aim with this change is not to re-engineer the waterfall-cli internals overall, just to add the ability for the existing design to handle passing back the list of comma separated options.

If you want to re-engineer how waterfall-cli does what it does, let's open a separate issue for that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't consider it re-engineering, but rather, making sure this implementation fits within the current design pattern. The current implementation seems to be introducing a new pattern whereby src/utils/construct-input-object.ts needs to handle the acceptsMultiple option, even though that file doesn't need to currently for data.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the change to src/utils/get-organized-arguments.ts Claude suggested when asked:

Changes-On-96646c.patch

Not including new tests, Claude seems to think that only a change to the src/utils/get-organized-arguments.ts file is necessary, not src/utils/construct-input-object.ts.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I've tested what you shared, and it seems to work too. I don't mind going with your patch if you'd prefer to do that, in terms of the parsing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: my testing is focussed on the multiple string values, not the numerics.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the patch gives you a head start that makes it easy to implement correctly & completely, versus what we discussed in person regarding saving some of the work for later, it'd make sense to do it correctly & completely from the outset.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest changes works for multiple strings and number options.

Comment thread src/utils/get-organized-arguments.ts Outdated
Comment on lines 82 to 96
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this integer and float validation won't work for acceptsMultiple options. Is that correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not tested that, but, I suspect you are correct.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most recent changes support multiple options too

@Peter-Sparksuite
Copy link
Copy Markdown
Contributor Author

Peter-Sparksuite commented Apr 10, 2026

Regarding #624 (comment)

When an option has acceptsMultiple: true, how does that impact the --help output? Just want to make sure it's clear we expect comma-separated values (e.g., --toppings=cheese,bacon instead of multiple options (e.g., --toppings=cheese --toppings=bacon).

I've modified the help logic that produces the 'accepts:' list to make it something that's automatically clarified, by dynamically adding (if it accepts multiple arguments), by adding 'comma separated' before the list of options is provided.

eg:

--holds, -h List of ingredients to omit. (accepts comma separated: ham, chicken, beef, bacon, *)

@WesCossick WesCossick merged commit 3342f8c into sparksuite:master Apr 13, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

Allow an option to have multiple values

2 participants