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

Simplify syntax of flags #11

Open
countvajhula opened this issue Sep 23, 2022 · 0 comments
Open

Simplify syntax of flags #11

countvajhula opened this issue Sep 23, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@countvajhula
Copy link
Owner

These are some examples of the syntax for flags at the moment:

(flag (verbose)
  ("-v" "--verbose" "Show detailed messages.")
  (verbose #t))

(flag (attempts n)
  ("-a" "--attempts" "Number of attempts to make")
  (attempts (string->number n)))
 
(flag (transaction n timeout)
  ("-t" "--transaction" "Size of transaction, and timeout value")
  (transaction (map string->number (list n timeout))))
 
(flag (links #:param [links null] link)
  ("-l" "--link" "Links to validate")
  (links (cons link (links))))

It seems that the goal of a flag function is typically to set the value of the corresponding parameter. So, should the syntax instead encode this transparently instead of requiring the user to do it explicitly? That is, we could treat the return value of the function as the value that the parameter should be set to, and do this behind the scenes. Otherwise, the syntax seems to have some redundancy, and in the most common cases (e.g. the first three examples above), the user would probably not even care to mention the parameter. The new versions would look like this:

(flag (verbose)
  ("-v" "--verbose" "Show detailed messages.")
  #t)

(flag (attempts n)
  ("-a" "--attempts" "Number of attempts to make")
  (string->number n))
 
(flag (transaction n timeout)
  ("-t" "--transaction" "Size of transaction, and timeout value")
  (map string->number (list n timeout)))
 
(flag (links #:param [links null] link)
  ("-l" "--link" "Links to validate")
  (cons link (links)))

This change would likely be backwards incompatible, and should probably be done in connection with #5 for that reason (as that is also backwards incompatible).

@countvajhula countvajhula added the enhancement New feature or request label Sep 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant