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
Parser generator #4
Comments
This is the current idea that I have... I don't love it. Too complicated.
|
The main problem I have with this right now is that it separates the business logic from the CLI itself. This is probably okay but the possible DX is just worse imo. // cli_def.ts
import compile from "...";
compile("./cli_gen.ts", {
name: "test",
action: true,
subcommands: [
{ name: "another", action: true },
],
}); // main.ts
import CLI from "./cli_gen.ts";
CLI.run({
test: () => {},
another: () => {},
}); I don't love this What if instead main can also lazily define the CLI, so when called with a special command it'll compile instead of running Keeps the definition and everything in one file, but introduces a bootstrapping problem // main.ts
import CLI from "./cli_gen.ts";
CLI.spec("./cli_gen.ts", () => ({
name: "something",
subcommands: [
{ name: "wow" },
{ name: "non_idiomatic_name", run: "nonIdiomaticName" },
],
}));
CLI.run({
something: () => {},
wow: () => {},
nonIdiomaticName: () => {},
}); This is maybe cleaner but it could get really bad for larger specs |
Fig specs are essentially a grammar definition as JSON. The parser isn't optimal for every CLI because it has to be general enough to run them all, but a parser generator can create the optimal parser for each CLI.
I want this to be seamless. It should feel like no effort at all to set it up for your project. Not sure exactly how this will look right now
The text was updated successfully, but these errors were encountered: