Skip to content

Better formatting of help text in terminals #34

@Ayake-QAware

Description

@Ayake-QAware

When running protocurl -h, the description of flags/arguments is not warped properly in the terminal.

It would be better to manually warp the usage text and ensure, that it fit within a specific width (e.g. 80 characters) - just like what other command line tools such as protoc -h do as well.

It is unclear, whether there is an option in cobra which automatically
adds newlines to ensure proper formatting.

The output should look similar to this:

Usage: protoc.exe [OPTION] PROTO_FILES
Parse PROTO_FILES and generate output based on the options given:
  -IPATH, --proto_path=PATH   Specify the directory in which to search for
                              imports.  May be specified multiple times;
                              directories will be searched in order.  If not
                              given, the current working directory is used.
                              If not found in any of the these directories,
                              the --descriptor_set_in descriptors will be
                              checked for required proto file.
  --version                   Show version info and exit.
  -h, --help                  Show this text and exit.
  --encode=MESSAGE_TYPE       Read a text-format message of the given type
                              from standard input and write it in binary
                              to standard output.  The message type must
                              be defined in PROTO_FILES or their imports.
  --deterministic_output      When using --encode, ensure map fields are
                              deterministically ordered. Note that this order
                              is not canonical, and changes across builds or

An implementation should not directly change the usage text for the flags. The usage for the flags should be written without any newlines - and a separate "rendering" function should take care of the formatting.

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