Skip to content

Make CLI conversation more user-friendly  #27

@bittner

Description

@bittner

As a waf-tool user
I want the CLI to give me helpful (and beautiful) error messages
So that it's easy to get results with the CLI
And I do not necessarily need to study the README or consult other documentation.

Expected Outcome

  1. All error messages are self-explanatory and give directions on how to fix the situation.
  2. The layout of output (progress status, error and warning messages, etc.) have a common, pleasant, Unix CLI style look, targeted to human consumption.

Current State (Examples)

Confusing error message (should say, "Argument UNIQUEID required" instead)

$ waf-tool tune
FATAL[2020-09-15T11:09:32+02:00] An error occured             error="accepts 1 arg(s), received 0"

Confusing error message (should say, "Please log in to your cluster" instead)

$ waf-tool tune asdasd
INFO[2020-09-15T11:11:34+02:00] Starting port forward...      port=9200
FATAL[2020-09-15T11:11:34+02:00] An error occured             error="error: You must be logged in to the server (Unauthorized)"

The layout of any output is not particularly human-friendly. Logrus seems optimized for APIs that pick up the text for easy parsing ("Logrus is a structured logger for Go").

Colored

What to make use of

The help screens are implemented well (see below). There could be a related hint added to hard-to-understand error messages if their content can help understanding the usage (e.g. "Use --help for additional help.").

$ waf-tool
Usage:
  waf-tool [flags]
  waf-tool [command]

Available Commands:
  help        Help about any command
  tune        Create ModSecurity rule exclusions for a given request unique ID

Flags:
  -h, --help      help for waf-tool
  -v, --verbose   Verbose log output
      --version   version for waf-tool

Use "waf-tool [command] --help" for more information about a command.
$ waf-tool tune --help
The tool will use the oc binary to start a port forward to the cluster's Elasticsearch.
Using the $KUBECONFIG token it will query ES for the given unique ID.

Usage:
  waf-tool tune [unique-id] [flags]

Flags:
      --es-custom-ca string           Custom CA certificate to trust (in PEM format)
      --es-custom-ca-file string      Path to custom CA certificate to trust (in PEM format)
  -k, --es-insecure-skip-tls-verify   If true, the server's certificate will not be checked for validity.
                                      This will make your HTTPS connections insecure
  -u, --es-url string                 Elasticsearch target URL (default "https://localhost:9200/")
  -h, --help                          help for tune

Global Flags:
  -v, --verbose   Verbose log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions