Comments (2)
This is the current idea that I have... I don't love it. Too complicated.
.
|- deno.json // defines the build task
|- main.ts // defines actions for commands, imports _parser.js
|- cli
| |- spec.ts // the spec definition file, purely declarative
| |- _parser.js // generated parser
from run-fig.
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.
The generated CLI either needs to be imported from the main file then have you hook into it so you can tell it what to run for each command, or have some kind of way to invoke an external function itself which feels too magical.
// 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
from run-fig.
Related Issues (18)
- Add `Fig.completion` subcommand
- Reimplement help logic
- Add benchmarks
- Argument and option data types
- Type safety HOT 2
- Add description dedenting for help HOT 1
- Host on NPM
- Host on deno.land/x
- Better API for error messages with help
- doc.deno.land doesn't give descriptions for parserDirectives
- Decide on a name for the library HOT 1
- Explain the vision and motivation for the library
- Rethink `testing`
- Ensure `testing` tests are implemented correctly
- Help shouldn't suggest flags if all flags are required HOT 1
- Ability to specify options multiple times and use the last one, by default
- Make it faster
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from run-fig.