Skip to content

Help output just SLIGHTLY wider than 80 characters #1469

Open

Description

@ferdnyc

The help text output by gh help (or just gh with no other arguments) is just slightly wider than 80 columns, but still line-wrapped at like 86 columns wide or whatever. That causes it to look especially bad in an 80-character window, without realizing any of the potential benefits from wider formatting.

Specifically, this is the output in an 80×24 terminal window:

$ gh
Work seamlessly with GitHub from the command line.

USAGE
  gh <command> <subcommand> [flags]

CORE COMMANDS
  issue:      Create and view issues
  pr:         Create, view, and checkout pull requests
  repo:       Create, clone, fork, and view repositories

ADDITIONAL COMMANDS
  alias:      Create command shortcuts
  api:        Make an authenticated GitHub API request
  completion: Generate shell completion scripts
  config:     Manage configuration for gh
  gist:       Create gists
  help:       Help about any command

FLAGS
  --help      Show help for command
  --version   Show gh version

EXAMPLES
  $ gh issue create
  $ gh repo clone cli/cli
  $ gh pr checkout 321

ENVIRONMENT VARIABLES
  GITHUB_TOKEN: an authentication token for API requests. Setting this avoids be
ing
  prompted to authenticate and overrides any previously stored credentials.
  
  GH_REPO: specify the GitHub repository in "OWNER/REPO" format for commands tha
t
  otherwise operate on a local repository.
  
  GH_EDITOR, GIT_EDITOR, VISUAL, EDITOR (in order of precedence): the editor too
l to use
  for authoring text.
  
  BROWSER: the web browser to use for opening links.
  
  DEBUG: set to any value to enable verbose output to standard error. Include va
lues "api"
  or "oauth" to print detailed information about HTTP requests or authentication
 flow.
  
  GLAMOUR_STYLE: the style to use for rendering Markdown. See
  https://github.com/charmbracelet/glamour#styles
  
  NO_COLOR: avoid printing ANSI escape sequences for color output.

LEARN MORE
  Use "gh <command> <subcommand> --help" for more information about a command.
  Read the manual at https://cli.github.com/manual

FEEDBACK
  Fill out our feedback form https://forms.gle/umxd3h31c7aMQFKG7
  Open an issue using “gh issue create -R cli/cli”

(The output above is collected from this version of the gh tool, installed on Fedora 32 from the official downloadable RPM package:)

$ gh --version
gh version 0.11.1 (2020-07-28)
https://github.com/cli/cli/releases/tag/v0.11.1

My argument here is not that the text has to be formatted to only 80 columns wide. Only that if it isn't going to fit in 80 columns, there should be no fixed-width line-wrapping, period.

Ideally the output would auto-wrap to fit the current terminal width. But failing that, it would actually be better to just output one line per paragraph, without doing any wrapping. This is one of those situations where doing the wrong thing ends up being worse than doing nothing.

Activity

  1. mislav commented on Jul 31, 2020

    @mislav
    Contributor

    My argument here is not that the text has to be formatted to only 80 columns wide. Only that if it isn't going to fit in 80 columns, there should be no fixed-width line-wrapping, period.

    Fully agreed! I was considering a help system that reformats all prose to fit available width, but to also cap it at a certain maximum width for readability.

    In the meantime, you can try viewing our man pages: man gh, man gh-pr-create, etc. They are a little rough, but you should have no line-wrapping problems there.

    But failing that, it would actually be better to just output one line per paragraph, without doing any wrapping.

    That would be good for small- to medium-sized terminal windows, but for extremely wide terminal windows that might lead to very long lines, which is hard to read.

  2. ferdnyc commented on Jul 31, 2020

    @ferdnyc
    Author

    But failing that, it would actually be better to just output one line per paragraph, without doing any wrapping.

    That would be good for small- to medium-sized terminal windows, but for extremely wide terminal windows that might lead to very long lines, which is hard to read.

    A fair point, there definitely should be some maximum. Print media formats prose into columns for a reason.

  3. ferdnyc commented on Aug 1, 2020

    @ferdnyc
    Author

    In the meantime, you can try viewing our man pages: man gh, man gh-pr-create, etc. They are a little rough, but you should have no line-wrapping problems there.

    Heh. Well, actually (from gh-api(1)):

    OPTIONS
           -F, --field=[]      Add a parameter of inferred type
    
           -H, --header=[]      Add an additional HTTP request header
    
           -i, --include[=false]      Include HTTP response headers in the output
    
           --input=""      The file to use as body for the HTTP request
    
           -X, --method="GET"      The HTTP method for the request
    
           --paginate[=false]      Make additional  HTTP  requests  to  fetch  all
           pages of results
    
           -f, --raw-field=[]      Add a string parameter
    
           --silent[=false]      Do not print the response body
    

    That's not actually so bad, though. Unfortunately, there's also a missing content issue.

    
    $ gh api --help|head -n 35|tail -n 15
      repository of the current directory;
    - if the value starts with "@", the rest of the value is interpreted as a
      filename to read the value from. Pass "-" to read from standard input.
    
    Raw request body may be passed from the outside via a file specified by '--input'.
    Pass "-" to read from standard input. In this mode, parameters specified via
    '--field' flags are serialized into URL query parameters.
    
    In '--paginate' mode, all pages of results will sequentially be requested until
    there are no more pages of results. For GraphQL requests, this requires that the
    original query accepts an '$endCursor: String' variable and that it fetches the
    'pageInfo{ hasNextPage, endCursor }' set of fields from a collection.
    
    USAGE
      gh api  [flags]
    

    vs.

    
    $ man gh-api|head -n 45 |tail -n 10  
    <standard input>:55: name expected (got a special character): treated as missing
                  · if  the value starts with "@", the rest of the value is inter‐
                    preted as a filename to read the value from. Pass "-" to  read
                    from standard input.
    
           Raw request body may be passed from the outside via a file specified by
           '--input'.  Pass "-" to read from standard input. In this mode, parame‐
           ters specified via
    
           In  '--paginate'  mode,  all  pages  of  results  will  sequentially be
           requested until there  are  no  more  pages  of  results.  For  GraphQL
           requests, this requires that the original query accepts an '$endCursor:
           String' variable and that it fetches the
    
    OPTIONS
           -F, --field=[]      Add a parameter of inferred type
    

    Looks like the first omission (which also triggers that error message at the start of the output) happens because '--field' falls right at the start of a line (line 55 in gh-api.1), and I guess a line beginning with ' is interpreted as the start of some sort of command sequence, in nroff. The second one, 'pageinfo{...' is also at the beginning of a line, so same thing.

  4. mislav commented on Aug 5, 2020

    @mislav
    Contributor

    Thanks for looking into this! It definitely looks like some markdown-to-roff encoding bug. We already have on our roadmap for this month an item to refresh our docs, particularly regarding how they are rendered to man and HTML formats. 👍

  5. added
    bug
    on Aug 5, 2020
  6. added
    priority-3
    on Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority-3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions