nginxinc/nginx-prometheus-exporter

CLI flags broken after kingpin migration

pgollangi opened this issue · 1 comments

Describe the bug
All nginx-prometheus-exporter supposed to work with single hyphen, for example -nginx.scrape-uri=http://localhost:8080/metrics as it was the case with GoLang flags.

However this is no longer the case after migrating CLI parser to alecthomas/kingpin.
CLI flags with single hyphens considered as short flags and reporting errors.

For example following command giving error:

$ nginx-prometheus-exporter -nginx.scrape-uri=http://localhost:8080/metrics
nginx-prometheus-exporter: error: unknown short flag '-n', try --help

To reproduce
Steps to reproduce the behavior:

  1. Run nginx-prometheus-exporter from source or build CLI binary from main branch and run nginx-prometheus-exporter

Expected behavior
nginx-prometheus-exporter should accept long flags with single hyphens

Your environment

  • Version of the Prometheus exporter - revision 3d70ede5acc92bb50dd0fc9caab80cdf1a83082e
  • Version of Docker/Kubernetes: 1.24
  • [if applicable] Kubernetes platform: GKE
  • Using NGINX or NGINX Plus: NGINX

Hi @pgollangi

we haven't released a new version with those changes yet and the plan was to have a breaking change release (bump to v1.0.0) because of that and other changes.
We could actually add a function to transform the single dash to a double and maybe add a warning that the single one is being deprecated 🤔