Using oclif to create 1 command per file without the need for package.json or etc #1118
Replies: 1 comment 1 reply
-
To be completely honest, something like commander might be a better fit for your use case but you might be able to get close if you copy this example, which uses esbuild and oclif's As stated in that repo's readme, it's not a use case that we officially support so you might have to hack some things together to get exactly what you want. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there. Apologies if any formatting sucks as I'm on mobile.
I'm hoping to use oclif to write CLI commands in typescript that I plan to run using
tsx
(semi pseudo code example below)I was wondering if there is a way to create an oclif command using extending the
Command
class as usual, and being able to run it with the arguments from eitherprocess.argv
ORDeno.args
? I haven't tested oclif specifically on Deno yet but if the method allows me to pass args myself, that would be preferable.On top of that, would there be a way to register commands programmatically, either by importing them (like eslint flat config), or by passing the module name (like eslint classic config)? I'd love to be able to use the autocomplete plugin, help plugin and potentially a few others.
I do understand this would likely not be as optimised as oclif can be, as I would be wanting to avoid the manifest and package.json. The goal is being able to just add the dependencies to the package.json and a single command is completely portable and freely shareable with e.g. co workers, or better yet, if the code is deno compatible and I can just import from
npm:@oclif/core
or a CDN or similar.I've added an example that is mostly is pseudo code, but does have some actual oclif code below. If there's any way to get this with the latest version of oclif, even if I have do some deep imports, that would be fantastic.
I hope that made sense! I'm totally in favour of something that is shorter or more concise if that somehow exists, I'm also willing to use something with more boilerplate. Very keen to find out if anything like this is even remotely possible!
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions