Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap help output lines #4559

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

mgaligniana
Copy link

@mgaligniana mgaligniana commented Feb 19, 2025

Closes #4508

What?

Wrap some lines of help output command

Why?

To be consistently

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have run linter locally (make lint) and all checks pass.
  • I have run tests locally (make tests) and all tests pass.
  • I have commented on my code, particularly in hard-to-understand areas.

Related PR(s)/Issue(s)

Final output is like this:

Start a test.

This also exposes a REST API to interact with it. Various k6 subcommands offer
a commandline interface for interacting with it.

Usage:
  k6 run [flags]

Examples:
  # Run a single VU, once.
  k6 run script.js

  # Run a single VU, 10 times.
  k6 run -i 10 script.js

  # Run 5 VUs, splitting 10 iterations between them.
  k6 run -u 5 -i 10 script.js

  # Run 5 VUs for 10s.
  k6 run -u 5 -d 10s script.js

  # Ramp VUs from 0 to 100 over 10s, stay there for 60s, then 10s down to 0.
  k6 run -u 0 -s 10s:100 -s 60s:100 -s 10s:0

  # Send metrics to an influxdb server
  k6 run -o influxdb=http://1.2.3.4:8086/k6

Flags:
  -u, --vus int                             number of virtual users (default 1)
  -d, --duration duration                   test duration limit
  -i, --iterations int                      script total iteration limit (among all VUs)
  -s, --stage stage                         add a stage, as `[duration]:[target]`
      --execution-segment string            limit execution to the specified segment, e.g. 10%, 1/3, 0.2:2/3
      --execution-segment-sequence string   the execution segment sequence
  -p, --paused                              start the test in a paused state
      --no-setup                            don't run setup()
      --no-teardown                         don't run teardown()
      --max-redirects int                   follow at most n redirects (default 10)
      --batch int                           max parallel batch reqs (default 20)
      --batch-per-host int                  max parallel batch reqs per host (default 6)
      --rps int                             limit requests per second
      --user-agent string                   user agent for http requests (default "k6/0.57.0 (https://k6.io/)")
      --http-debug string[="headers"]       log all HTTP requests and responses. Excludes body by default.
                                            To include body use '--http-debug=full'
      --insecure-skip-tls-verify            skip verification of TLS certificates
      --no-connection-reuse                 disable keep-alive connections
      --no-vu-connection-reuse              don't reuse connections between iterations
      --min-iteration-duration duration     minimum amount of time k6 will take executing a single iteration
  -w, --throw                               throw warnings (like failed http requests) as errors
      --blacklist-ip ip range               blacklist an ip range from being called
      --block-hostnames pattern             block a case-insensitive hostname pattern,
                                            with optional leading wildcard, from being called
      --summary-trend-stats stats           define stats for trend metrics (response times), one or more as 'avg,p(95),...' (default 'avg,min,med,max,p(90),p(95)')
      --summary-time-unit string            define the time unit used to display the trend stats.
                                            Possible units are: 's', 'ms' and 'us'
      --system-tags strings                 only include these system tags in metrics (default
                                            "proto,subproto,status,method,url,name,group,check,error,error_code,tls_version,scenario,service,expected_response")
      --tag tag                             add a tag to be applied to all samples, as `[name]=[value]`
      --console-output string               redirects the console logging to the provided output file
      --discard-response-bodies             Read but don't process or save HTTP response bodies
      --local-ips string                    Client IP Ranges and/or CIDRs from which each VU will be making requests,
                                            e.g. '192.168.220.1,192.168.0.10-192.168.0.25', 'fd:1::0/120', etc.
      --dns string                          DNS resolver configuration. Possible ttl values are:
                                            'inf' for a persistent cache, '0' to disable the cache, or a positive duration, e.g. '1s', '1m', etc.
                                            Milliseconds are assumed if no unit is provided.
                                            Possible select values to return a single IP are: 'first', 'random' or 'roundRobin'.
                                            Possible policy values are: 'preferIPv4', 'preferIPv6', 'onlyIPv4', 'onlyIPv6' or 'any'.
                                             (default "ttl=5m,select=random,policy=preferIPv4")
      --include-system-env-vars             pass the real system environment variables to the runtime (default true)
      --compatibility-mode string           JavaScript compiler compatibility mode, "extended" or "base"
                                            base: pure Sobek - Golang JS VM supporting ES6+
                                            extended: base + sets "global" as alias for "globalThis"
                                             (default "extended")
  -t, --type string                         override test type, "js" or "archive"
  -e, --env VAR=value                       add/override environment variable with VAR=value
      --no-thresholds                       don't run thresholds
      --no-summary                          don't show the summary at the end of the test
      --summary-export string               output the end-of-test summary report to JSON file
      --traces-output string                set the output for k6 traces, possible values are none,otel[=host:port] (default "none")
  -o, --out uri                             uri for an external metrics database
  -l, --linger                              keep the API server alive past test end
      --no-usage-report                     don't send anonymous usagestats (https://grafana.com/docs/k6/latest/set-up/usage-collection/)
  -h, --help                                help for run

Global Flags:
  -a, --address string      address for the REST API server (default "localhost:6565")
  -c, --config string       JSON config file (default "/Users/mgaligniana/Library/Application Support/k6/config.json")
      --log-format string   log output format
      --log-output string   change the output for k6 logs, possible values are stderr,stdout,none,loki[=host:port],file[=./path.fileformat] (default "stderr")
      --no-color            disable colored output
      --profiling-enabled   enable profiling (pprof) endpoints, k6's REST API should be enabled as well
  -q, --quiet               disable progress updates
  -v, --verbose             enable verbose logging

@CLAassistant
Copy link

CLAassistant commented Feb 19, 2025

CLA assistant check
All committers have signed the CLA.

@mgaligniana mgaligniana marked this pull request as ready for review February 19, 2025 01:27
@mgaligniana mgaligniana requested a review from a team as a code owner February 19, 2025 01:27
@mgaligniana mgaligniana requested review from inancgumus and olegbespalov and removed request for a team February 19, 2025 01:27
@inancgumus
Copy link
Member

inancgumus commented Feb 20, 2025

Hi, @mgaligniana; thanks for your PR 🙇 Does this PR close #4508 or update it? The original issue was about making each flag line 119 characters long. Have you considered this?

@mgaligniana
Copy link
Author

Hi, @mgaligniana; thanks for your PR 🙇 Does this PR close #4508 or update it? The original issue was about making each flag line 119 characters long. Have you considered this?

Hi Inanc! Oops, maybe I misunderstood the issue? So I break the lines with the //nolint:lll comment to fix the error when running make check

i.e.

internal/cmd/options.go:XX:1                                    lll              The line is 165 characters long, which exceeds the maximum of 120 characters.

And in addition: break also the lines where the output was too long

I didn't understand this part sorry:

Have you considered this

@inancgumus
Copy link
Member

inancgumus commented Feb 21, 2025

Oops, maybe I misunderstood the issue?

No worries. I believe the original issue was talking about outputting each usage text line 119 characters at most.

break also the lines where the output was too long

Yes, this is the issue's goal, I believe.

I didn't understand this part sorry:

We use the spf13/plag package for k6 flags. The FlagSet.FlagUsages() method (that I linked previously (also here)) automatically wraps usage lines. I suggested taking a look at it to see if it solves the issue.

Hope this helps 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Help output should be consistently wrapped
3 participants