This repository was archived by the owner on May 26, 2025. It is now read-only.
Start making vtest command arguments less positional#43
Closed
nigoroll wants to merge 1 commit intovtest:masterfrom
Closed
Start making vtest command arguments less positional#43nigoroll wants to merge 1 commit intovtest:masterfrom
nigoroll wants to merge 1 commit intovtest:masterfrom
Conversation
Our common pattern of argument parsing is basically
for (; *av != NULL; av++) {
// parse first set of arguments
if (unknown_argument)
break;
}
for (; *av != NULL; av++) {
// parse second set of arguments
if (unknown_argument)
break;
}
// ...
This makes vtest command arguments "semi-positional": Within each set,
they behave like named arguments, but once parsing progressed to the
next set, they behave like positional arguments. This is explicitly
mentioned in the documentation, for example for txreq/txresp:
"These three switches can appear in any order but must come
before the following ones."
While properly documented, this is un-POLA behavior.
This patch changes this behavior for the first set of txreq/txresp
arguments in a simplistic way by filtering known arguments out of the
argument vector. The drawback of the simplistic approach is that
argument values of a "later stage" can not be the same string as
argument names of an "earlier stage". For example, the following would
no onger work:
txreq -body -nouseragent
Collaborator
Author
|
Continued as vtest/VTest2#4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NB: This patch does not work with vtest as-is because of other missing patches. Before running into more of a chicken/egg double maintenance situation, I would prefer to achieve consensus about https://github.com/nigoroll/vtest2/ (see also varnishcache/varnish-cache#4333). This patch currently is in vtest2 WIP as nigoroll/VTest2@a907e42, but I am not sold on it.
This ticket is to ask about feedback.
Our common pattern of argument parsing is basically
This makes vtest command arguments "semi-positional": Within each set, they behave like named arguments usually do, but once parsing progressed to the next set, they behave like positional arguments. This is explicitly mentioned in the documentation, for example for txreq/txresp:
While properly documented, this is un-POLA behavior.
This patch changes this behavior for the first set of txreq/txresp arguments in a simplistic way by filtering known arguments out of the argument vector. The drawback of the simplistic approach is that argument values of a "later stage" can not be the same string as argument names of an "earlier stage". For example, the following would no longer work:
Do we want this compromise? If not, I would prefer to just stick to "RTFM".
In Response to vtest/VTest2#1