Skip to content

Support arrays in CLI arguments#1300

Merged
Perryvw merged 5 commits intoTypeScriptToLua:masterfrom
hazzard993:support-cli-arrays
Jul 9, 2022
Merged

Support arrays in CLI arguments#1300
Perryvw merged 5 commits intoTypeScriptToLua:masterfrom
hazzard993:support-cli-arrays

Conversation

@hazzard993
Copy link
Copy Markdown
Contributor

@hazzard993 hazzard993 commented Jul 7, 2022

Closes #1267

Allows TSTL to receive arrays for its parameters via the CLI from a comma separated value

tstl -p tsconfig.json --noResolvePaths patha,pathb

Let me know if there's some other edge cases I may be missing

Edit:
Also supporting arrays of objects parameters (only effects luaPlugins) by parsing a JSON array instead of a comma separated string

tstl -p tsconfig.json --luaPlugins '[{ "name": "my-plugin" }]'

@Zamiell
Copy link
Copy Markdown
Contributor

Zamiell commented Jul 7, 2022

Can we add objects too? It would be really nice to specify plugins as command-line options. (I have a crash debugger plugin that is only conditionally turned on when debugging.)

@hazzard993
Copy link
Copy Markdown
Contributor Author

How would you like to see this on the CLI?

Current option I'm thinking of is

$ tstl -p tsconfig.json --luaPlugins my-plugin-1,my-plugin-2@my-plugin-import
                                     |  name   | |  name   | |    import    |

But this could become more complex if we add more options to plugins

Initially I thought JSON object as both name and import can be specified for a single plugin and we can have multiple plugins. This helps if we support more options in the future

$ tstl -p tsconfig.json --luaPlugins '[{ "name": "my-plugin-1" }, { "name": "my-plugin-2" }]'

It looks quite verbose but at least grants the ability to control these plugins via CLI

Perhaps name only might be a solution

$ tstl -p tsconfig.json --luaPlugins my-plugin-1,my-plugin-2

Or maybe we need some other CLI options to include/exclude plugins so users don't have to deal with a potentially tricky CLI syntax

TypeScript doesn't have any examples to pull from and the last time I needed to specify an object via CLI I just used JSON 🤔

@Perryvw
Copy link
Copy Markdown
Member

Perryvw commented Jul 7, 2022

How would you like to see this on the CLI?

Current option I'm thinking of is

$ tstl -p tsconfig.json --luaPlugins my-plugin-1,my-plugin-2@my-plugin-import
                                     |  name   | |  name   | |    import    |

But this could become more complex if we add more options to plugins

Initially I thought JSON object as both name and import can be specified for a single plugin and we can have multiple plugins. This helps if we support more options in the future

$ tstl -p tsconfig.json --luaPlugins '[{ "name": "my-plugin-1" }, { "name": "my-plugin-2" }]'

It looks quite verbose but at least grants the ability to control these plugins via CLI

Perhaps name only might be a solution

$ tstl -p tsconfig.json --luaPlugins my-plugin-1,my-plugin-2

Or maybe we need some other CLI options to include/exclude plugins so users don't have to deal with a potentially tricky CLI syntax

TypeScript doesn't have any examples to pull from and the last time I needed to specify an object via CLI I just used JSON 🤔

I'd say probably just straight up json syntax, but I'd also be okay with doing this in a followup PR

@Zamiell
Copy link
Copy Markdown
Contributor

Zamiell commented Jul 7, 2022

$ tstl -p tsconfig.json --luaPlugins '[{ "name": "my-plugin-1" }, { "name": "my-plugin-2" }]'

yes, this format is what i intuitively expect to work.
i was surprised that it wasn't already built in to tstl when i tried this a few months ago

@hazzard993
Copy link
Copy Markdown
Contributor Author

Thanks all! I'll just clean up my PR a bit for review

@hazzard993
Copy link
Copy Markdown
Contributor Author

Ready for review @Perryvw!

@Perryvw Perryvw merged commit 33af9ea into TypeScriptToLua:master Jul 9, 2022
@hazzard993 hazzard993 deleted the support-cli-arrays branch July 9, 2022 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cli (tlsl) doesn't seem to be supporting array as argument

3 participants