denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
93.99k stars 5.23k forks source link

cli: only show relevant options #24263

Open scarf005 opened 2 months ago

scarf005 commented 2 months ago

currently the output of --help flag in deno is quite verbose:

$ deno add --help
Add dependencies to the configuration file.

  deno add @std/path

You can add multiple dependencies at once:

  deno add @std/path @std/assert

Usage: deno add [OPTIONS] <packages>...

Arguments:
  <packages>...
          List of packages to add

Options:
  -q, --quiet
          Suppress diagnostic output

  -h, --help
          Print help (see a summary with '-h')

      --unstable
          Enable unstable features and APIs

      --unstable-bare-node-builtins
          Enable unstable bare node builtins feature

          [env: DENO_UNSTABLE_BARE_NODE_BUILTINS=]

      --unstable-byonm
          Enable unstable 'bring your own node_modules' feature

          [env: DENO_UNSTABLE_BYONM=]

      --unstable-sloppy-imports
          Enable unstable resolving of specifiers by extension probing, .js to .ts, and directory probing.

          [env: DENO_UNSTABLE_SLOPPY_IMPORTS=]

      --unstable-broadcast-channel
          Enable unstable `BroadcastChannel` API

      --unstable-cron
          Enable unstable Deno.cron API

      --unstable-ffi
          Enable unstable FFI APIs

      --unstable-fs
          Enable unstable file system APIs

      --unstable-http
          Enable unstable HTTP APIs

      --unstable-kv
          Enable unstable Key-Value store APIs

      --unstable-net
          Enable unstable net APIs

      --unstable-temporal
          Enable unstable Temporal API

      --unstable-unsafe-proto
          Enable unsafe __proto__ support. This is a security risk.

      --unstable-webgpu
          Enable unstable `WebGPU` API

      --unstable-worker-options
          Enable unstable Web Worker APIs

the --unstable-* flags are irrelevant but uses many lines. only showing such information where needed would declutter --help (and other subcommands) and help users find info quickly.

Others

related: https://garnix.io/blog/contextual-cli

I'm interested in opening a PR (pointers on where to look at would be appreciated!)

MujahedSafaa commented 2 months ago

@lucacasonato When should the --unstable-* options be displayed to the user?