Skip to content
This repository was archived by the owner on May 26, 2025. It is now read-only.

Conversation

@nigoroll
Copy link
Collaborator

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

	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 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:

"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 longer work:

	txreq -body -nouseragent

Do we want this compromise? If not, I would prefer to just stick to "RTFM".

In Response to vtest/VTest2#1

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
@nigoroll
Copy link
Collaborator Author

Continued as vtest/VTest2#4

@nigoroll nigoroll closed this May 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant