Skip to content

Reformat output of "nvm --help" and others to consider line-wrapping #2209

Open
@jsejcksn

Description

@jsejcksn

It is very difficult to read the output of nvm --help (and other outputs with long lines) on the default terminal width of 80 characters. Here's what it looks like:

Node Version Manager (v0.35.3)

Note: <version> refers to any version-like string nvm understands. This includes
:
  - full or partial version numbers, starting with an optional "v" (0.10, v0.1.2
, v1)
  - default (built-in) aliases: node, stable, unstable, iojs, system
  - custom aliases you define with `nvm alias foo`

 Any options that produce colorized output should respect the `--no-colors` opti
on.

Usage:
  nvm --help                                Show this message
  nvm --version                             Print out the installed version of n
vm
  nvm install [-s] <version>                Download and install a <version>, [-
s] from source. Uses .nvmrc if available
    --reinstall-packages-from=<version>     When installing, reinstall packages 
installed in <node|iojs|node version number>
    --lts                                   When installing, only select from LT
S (long-term support) versions
    --lts=<LTS name>                        When installing, only select from ve
rsions for a specific LTS line
    --skip-default-packages                 When installing, skip the default-pa
ckages file if it exists
    --latest-npm                            After installing, attempt to upgrade
 to the latest working npm on the given node version
    --no-progress                           Disable the progress bar on any down
loads
  nvm uninstall <version>                   Uninstall a version
  nvm uninstall --lts                       Uninstall using automatic LTS (long-
term support) alias `lts/*`, if available.
  nvm uninstall --lts=<LTS name>            Uninstall using automatic alias for 
provided LTS line, if available.
  nvm use [--silent] <version>              Modify PATH to use <version>. Uses .
nvmrc if available
    --lts                                   Uses automatic LTS (long-term suppor
t) alias `lts/*`, if available.
    --lts=<LTS name>                        Uses automatic alias for provided LT
S line, if available.
  nvm exec [--silent] <version> [<command>] Run <command> on <version>. Uses .nv
mrc if available
    --lts                                   Uses automatic LTS (long-term suppor
t) alias `lts/*`, if available.
    --lts=<LTS name>                        Uses automatic alias for provided LT
S line, if available.
  nvm run [--silent] <version> [<args>]     Run `node` on <version> with <args> 
as arguments. Uses .nvmrc if available
    --lts                                   Uses automatic LTS (long-term suppor
t) alias `lts/*`, if available.
    --lts=<LTS name>                        Uses automatic alias for provided LT
S line, if available.
  nvm current                               Display currently activated version 
of Node
  nvm ls [<version>]                        List installed versions, matching a 
given <version> if provided
    --no-colors                             Suppress colored output
    --no-alias                              Suppress `nvm alias` output
  nvm ls-remote [<version>]                 List remote versions available for i
nstall, matching a given <version> if provided
    --lts                                   When listing, only show LTS (long-te
rm support) versions
    --lts=<LTS name>                        When listing, only show versions for
 a specific LTS line
    --no-colors                             Suppress colored output
  nvm version <version>                     Resolve the given description to a s
ingle local version
  nvm version-remote <version>              Resolve the given description to a s
ingle remote version
    --lts                                   When listing, only select from LTS (
long-term support) versions
    --lts=<LTS name>                        When listing, only select from versi
ons for a specific LTS line
  nvm deactivate                            Undo effects of `nvm` on current she
ll
  nvm alias [<pattern>]                     Show all aliases beginning with <pat
tern>
    --no-colors                             Suppress colored output
  nvm alias <name> <version>                Set an alias named <name> pointing t
o <version>
  nvm unalias <name>                        Deletes the alias named <name>
  nvm install-latest-npm                    Attempt to upgrade to the latest wor
king `npm` on the current node version
  nvm reinstall-packages <version>          Reinstall global `npm` packages cont
ained in <version> to current version
  nvm unload                                Unload `nvm` from shell
  nvm which [current | <version>]           Display path to installed node versi
on. Uses .nvmrc if available
  nvm cache dir                             Display path to the cache directory 
for nvm
  nvm cache clear                           Empty cache directory for nvm

Example:
  nvm install 8.0.0                     Install a specific version number
  nvm use 8.0                           Use the latest available 8.0.x release
  nvm run 6.10.3 app.js                 Run app.js using node 6.10.3
  nvm exec 4.8.3 node app.js            Run `node app.js` with the PATH pointing
 to node 4.8.3
  nvm alias default 8.1.0               Set default node version on a shell
  nvm alias default node                Always default to the latest available n
ode version on a shell

Note:
  to remove, delete, or uninstall nvm - just remove the `$NVM_DIR` folder (usual
ly `~/.nvm`)

There are different approaches to improve the experience.

One approach is simply to add line breaks in between entries. This decreases the vertical density of information, has significantly-improved scannability, and is still responsive to variable-width terminals:

Node Version Manager (v0.35.3)

Note: <version> refers to any version-like string nvm understands. This includes
:

  - full or partial version numbers, starting with an optional "v" (0.10, v0.1.2
, v1)

  - default (built-in) aliases: node, stable, unstable, iojs, system

  - custom aliases you define with `nvm alias foo`

 Any options that produce colorized output should respect the `--no-colors` opti
on.

Usage:

  nvm --help                                Show this message

  nvm --version                             Print out the installed version of n
vm

  nvm install [-s] <version>                Download and install a <version>, [-
s] from source. Uses .nvmrc if available

    --reinstall-packages-from=<version>     When installing, reinstall packages 
installed in <node|iojs|node version number>

    --lts                                   When installing, only select from LT
S (long-term support) versions

    --lts=<LTS name>                        When installing, only select from ve
rsions for a specific LTS line

    --skip-default-packages                 When installing, skip the default-pa
ckages file if it exists

    --latest-npm                            After installing, attempt to upgrade
 to the latest working npm on the given node version

    --no-progress                           Disable the progress bar on any down
loads

  nvm uninstall <version>                   Uninstall a version

...etc.

Another way is keeping the indentation as-is and hard-wrapping lines at 80 characters. This approach doesn't utilize the available display area in wider terminals:

Node Version Manager (v0.35.3)

Note: <version> refers to any version-like string nvm understands. This 
includes:
  - full or partial version numbers, starting with an optional "v" (0.10, 
    v0.1.2, v1)
  - default (built-in) aliases: node, stable, unstable, iojs, system
  - custom aliases you define with `nvm alias foo`

 Any options that produce colorized output should respect the `--no-colors` 
 option.

Usage:
  nvm --help                                Show this message
  nvm --version                             Print out the installed version of
                                            nvm
  nvm install [-s] <version>                Download and install a <version>,
                                            [-s] from source. Uses .nvmrc if 
                                            available
    --reinstall-packages-from=<version>     When installing, reinstall packages 
                                            installed in <node|iojs|node 
                                            version number>
    --lts                                   When installing, only select from 
                                            LTS (long-term support) versions
    --lts=<LTS name>                        When installing, only select from 
                                            versions for a specific LTS line
    --skip-default-packages                 When installing, skip the
                                            default-packages file if it exists
    --latest-npm                            After installing, attempt to 
                                            upgrade to the latest working npm 
                                            on the given node version
    --no-progress                           Disable the progress bar on any 
                                            downloads
  nvm uninstall <version>                   Uninstall a version

...etc.

Another tool to look at is fold.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions