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

Drop placeholders to display default value for flags where it is set. #1207

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

alexbozhenko
Copy link
Contributor

@alexbozhenko alexbozhenko commented Dec 19, 2024

Dropped from all these lines:

# rg -e  '.Default\(.*.PlaceHolder' -e '.PlaceHolder\(.*Default'

Test plan:

# diff --minimal --context=0 <(nats --help-long) <(go run ./nats --help-long)
*** /dev/fd/63  2025-01-24 14:18:36.058857257 -0800
--- /dev/fd/62  2025-01-24 14:18:36.058857257 -0800
***************
*** 15 ****
!       --connection-name=NAME    Nickname to use for the underlying NATS
--- 15,16 ----
!       --connection-name="NATS CLI Version (devel)"
!                                 Nickname to use for the underlying NATS
***************
*** 24 ****
!       --timeout=DURATION        Time to wait on responses from NATS
--- 25 ----
!       --timeout=5s              Time to wait on responses from NATS
***************
*** 79,82 ****
!     --expire-warn=DURATION  Warn about certs expiring this soon (1w; 0 to
!                             disable)
!     --ocsp                  Report OCSP information, if any
!     --[no-]pem              Show PEM Certificate blocks (true)
--- 80,82 ----
!     --expire-warn=1w  Warn about certs expiring this soon (1w; 0 to disable)
!     --ocsp            Report OCSP information, if any
!     --[no-]pem        Show PEM Certificate blocks (true)
***************
*** 589 ****
!     --backoff-steps=STEPS        Number of steps to use when creating the
--- 589 ----
!     --backoff-steps=10           Number of steps to use when creating the
***************
*** 591 ****
!     --backoff-min=MIN            The shortest backoff period that will be
--- 591 ----
!     --backoff-min=1m             The shortest backoff period that will be
***************
*** 593 ****
!     --backoff-max=MAX            The longest backoff period that will be
--- 593 ----
!     --backoff-max=20m            The longest backoff period that will be
***************
*** 632 ****
!                                  14:18:36)
--- 632 ----
!                                  14:18:37)
***************
*** 653 ****
!         --backoff-steps=STEPS      Number of steps to use when creating the
--- 653 ----
!         --backoff-steps=10         Number of steps to use when creating the
***************
*** 655 ****
!         --backoff-min=MIN          The shortest backoff period that will be
--- 655 ----
!         --backoff-min=1m           The shortest backoff period that will be
***************
*** 657 ****
!         --backoff-max=MAX          The longest backoff period that will be
--- 657 ----
!         --backoff-max=20m          The longest backoff period that will be
***************
*** 741 ****
!     --backoff-steps=STEPS        Number of steps to use when creating the
--- 741 ----
!     --backoff-steps=10           Number of steps to use when creating the
***************
*** 743 ****
!     --backoff-min=MIN            The shortest backoff period that will be
--- 743 ----
!     --backoff-min=1m             The shortest backoff period that will be
***************
*** 745 ****
!     --backoff-max=MAX            The longest backoff period that will be
--- 745 ----
!     --backoff-max=20m            The longest backoff period that will be
***************
*** 784 ****
!                                  14:18:36)
--- 784 ----
!                                  14:18:37)
***************
*** 1184,1193 ****
!     --connect-warn=DURATION      Warning threshold to allow for establishing
!                                  connections
!     --connect-critical=DURATION  Critical threshold to allow for establishing
!                                  connections
!     --rtt-warn=DURATION          Warning threshold to allow for server RTT
!     --rtt-critical=DURATION      Critical threshold to allow for server RTT
!     --req-warn=DURATION          Warning threshold to allow for full round trip
!                                  test
!     --req-critical=DURATION      Critical threshold to allow for full round trip
!                                  test
--- 1184,1191 ----
!     --connect-warn=500ms   Warning threshold to allow for establishing
!                            connections
!     --connect-critical=1s  Critical threshold to allow for establishing
!                            connections
!     --rtt-warn=500ms       Warning threshold to allow for server RTT
!     --rtt-critical=1s      Critical threshold to allow for server RTT
!     --req-warn=500ms       Warning threshold to allow for full round trip test
!     --req-critical=1s      Critical threshold to allow for full round trip test
***************
*** 1240 ****
!     --content=REGEX          Regular expression to check the content against
--- 1238 ----
!     --content=.              Regular expression to check the content against
***************
*** 1413 ****
!         --state=STATE           Limits responses only to those connections that
--- 1411 ----
!         --state=open            Limits responses only to those connections that
***************
*** 1481 ****
!     --filter-state=STATE      Filter on a specific account state (open, closed,
--- 1479 ----
!     --filter-state=open       Filter on a specific account state (open, closed,
***************
*** 1908,1912 ****
!     --[no-]progress     Enables or disables progress reporting using a progress
!                         bar
!     --check             Checks the Stream for health prior to backup
!     --[no-]consumers    Enable or disable consumer backups
!     --chunk-size=BYTES  Sets a specific chunk size that the server will send
--- 1906,1910 ----
!     --[no-]progress       Enables or disables progress reporting using a
!                           progress bar
!     --check               Checks the Stream for health prior to backup
!     --[no-]consumers      Enable or disable consumer backups
!     --chunk-size="128KB"  Sets a specific chunk size that the server will send

@alexbozhenko
Copy link
Contributor Author

@ripienaar WDYT?
Maybe it will be nicer to just change fisk to display both, e.g.
instead of
--backoff-steps=STEPS
do this
--backoff-steps=STEPS(10)
?

@@ -117,14 +117,14 @@ func configureAuthAccountCommand(auth commandHost) {
f.Flag("jetstream", "Enables JetStream").Default("false").IsSetByUser(&c.jetStreamIsSet).BoolVar(&c.jetStream)
f.Flag("js-consumers", "Sets the maximum Consumers the account can have").Default("-1").IsSetByUser(&c.maxConsumersIsSet).Int64Var(&c.maxConsumers)
f.Flag("js-disk", "Sets a Disk Storage quota").PlaceHolder("BYTES").StringVar(&c.storeMaxString)
f.Flag("js-disk-stream", "Sets the maximum size a Disk Storage stream may be").PlaceHolder("BYTES").Default("-1").StringVar(&c.storeMaxStreamString)
f.Flag("js-disk-stream", "Sets the maximum size a Disk Storage stream may be").Default("-1").StringVar(&c.storeMaxStreamString)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think universally just updating all of these with a script is the right approach, in the previous one where the default is something useful like 1w it makes sense to show the default, here -1 is more an implementation detail than a useful default users should know about so the placement string should be used in stead.

We will need to evaluate each case and decide if it makes sense to show the default.

A lot of this code was written before fisk has IsSetByUser() and so some of these defaults are there only to compensate for the lack of that feature rather than a default thats useful to the user.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ripienaar would you be open to a separate PR, where places that use "meaningless" defaults are update to IsSetByUser ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes for now let’s drop placeholders only where it make sense. Later we can move to IsSetByUser()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed those

Signed-off-by: Alex Bozhenko <[email protected]>
@alexbozhenko alexbozhenko marked this pull request as ready for review January 24, 2025 22:20
@alexbozhenko
Copy link
Contributor Author

We can clean up those were both IsSetByUser and default is used separately:
# rg -e '.Default\(.*.IsSetByUser' -e '.IsSetByUser\(.*Default'

E.g. this should show a placeholder, and should not show default, right?

# nats  auth account add -h  | grep 'Maximum allowed connections'
  --connections=-1           Maximum allowed connections

Copy link
Collaborator

@ripienaar ripienaar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, just the one bit of redundant info we can now remove

@@ -40,7 +40,7 @@ func configureAccountTLSCommand(srv *fisk.CmdClause) {
c := &ActTLSCmd{}

tls := srv.Command("tls", "Report TLS chain for connected server").Action(c.showTLS)
tls.Flag("expire-warn", "Warn about certs expiring this soon (1w; 0 to disable)").Default("1w").PlaceHolder("DURATION").DurationVar(&c.expireWarnDuration)
tls.Flag("expire-warn", "Warn about certs expiring this soon (1w; 0 to disable)").Default("1w").DurationVar(&c.expireWarnDuration)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets make this Warn about certs expiring this soon, 0 to disable

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.

2 participants