CLI: Transform JS object of CLI options to a string
What is the problem this feature would solve?
-
I made a script with effect-cli and I want to run it programmatically for any reason.
Maybe I want to delegate logic dynamically based on a flag, but am limited to a bundler that cannot handle dynamic
import()s properly, so have to resort toexecSync()or the like. -
I can create an option spec for some third-party script and avoid crafting strings.
What is the feature you are proposing to solve the problem?
A way to convert an option spec to a string with flags.
What alternatives have you considered?
Crafting strings works (but is error-prone).
@strogonoff - I'm not sure I'm understanding properly.
Are you looking for a way to essentially get the usage statement for an option?
If so, you can already do that:
import { HelpDoc, Options, Usage } from "@effect/cli"
const fooOption = Options.text("foo")
const fooUsage = Options.getUsage(fooOption)
const renderedUsage = HelpDoc.toAnsiText(Usage.getHelp(fooUsage))
console.log(renderedUsage)
// --foo text
@strogonoff - I'm going to go ahead and close this issue as I think my answer might (?) cover your use case.
If not, please provide more details based on my questions I'll be happy to re-open!