[go: nahoru, domu]

Skip to content
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

Using with Deno #1803

Closed
shadowspawn opened this issue Sep 25, 2022 · 3 comments
Closed

Using with Deno #1803

shadowspawn opened this issue Sep 25, 2022 · 3 comments

Comments

@shadowspawn
Copy link
Collaborator
shadowspawn commented Sep 25, 2022

I was looking at what might be needed to get Commander working in Deno. I discovered Commander is usable through the CDN https://esm.sh without code changes, including the TypeScript typing. Very clever!

// cli.ts
import { Command } from "https://esm.sh/commander";
const program = new Command();
program.parse();
$ deno run --allow-read --allow-env cli.ts --help
Usage: cli [options]

Options:
  -h, --help  display help for command

I found two limitations:

  • the terminal width is unknown unless specify --unstable, so help wraps at column 80 by default
  • stand-alone executable subcommands do not work

(The terminal width presumably requires consoleSize: https://deno.land/api@v1.25.4?unstable=&s=Deno.consoleSize )
Update: terminal width working in Deno v1.28.0.

@shadowspawn shadowspawn added the docs README (or other docs) could be improved label Sep 29, 2022
@shadowspawn
Copy link
Collaborator Author
shadowspawn commented Oct 29, 2022

Also working with the unstable npm support. Support for TypeScript typing from Deno v1.27.0.

// cli.ts
import { Command } from "npm:commander";
const program = new Command();
program.parse();
$ deno --unstable run --allow-read cli.ts --help
Usage: cli [options]

Options:
  -h, --help  display help for command

Deno roadmap for npm specifiers: denoland/deno#15960

@shadowspawn
Copy link
Collaborator Author
shadowspawn commented Nov 15, 2022

With Deno v1.28.0:

  • no longer need --unstable
  • TypeScript typing from import working
  • help wraps at terminal width

@shadowspawn shadowspawn removed the docs README (or other docs) could be improved label Nov 25, 2022
@shadowspawn
Copy link
Collaborator Author

I did some more testing and didn't find any problems with Deno v1.28.0. Nice work by them!

I was wondering about adding an example import to the README in the program section, but nobody has asked about Deno, and many (most) npm modules are now available using the npm:foo import. So perhaps just expected behaviour now for Deno users!

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

No branches or pull requests

1 participant