* Akash Rawal <argm...@gmail.com> [170331 23:34]:
Breaking the order-insensitive and idempotent model of command line processing is an absolute no-go. It will definitely break many scripts out there. We do wish to make it easy to transition from Wget to Wget2 and this is a huge change in how options are processed. Also, I see no clear advantages to why this should be required.Hello,First of all, thanks for the initial review of my proposal! I have made some changes in response to the comments as well as last mail on the mailing list by Darshit Shah. Kindly consider reviewing it. For reference here is the link. https://docs.google.com/document/d/1SBM-jNG5dJL85C7iK9aid2eDlByrxOsYUNDrk4049vQ/edit?usp=sharing The proposal is still not final, in the sense that I am analysing the code for further ideas of what can be customized using plugins. I was asked to elaborate on rewriting of command line option processing code. So here are my thoughts on it. The current code in src/options.c has following drawbacks: - Built around order-insensitive and idempotent model (Supplying an option modifies a variable). This might be adequete for wget, but might not be the case for plugins. Repeated options or order of options can matter for plugins.
No. Plugins should not be allowed to tinker with certain core functionalities and that includes how options are processed.- The need for keeping the list of options sorted. I don't think we can expect plugin writers to do the same.
Which is a very good thing. Keeping everything at compile time means we can have most of that code on the stack without the need for costly dynamic memory allocations on each invokation. Options processing code should definitely not be dynamic.- And most importantly, options cannot be added at runtime.
So far I think rewriting the option processing code would be easier than trying to patch existing code to support custom options. Some parts of the original code could be reused but structure would undergo a drastic change anyway.
Easier? Have you every tried writing one? The number of use cases and corner cases you'd have to handle is massive. That alone could be an entire GSoC project. You can't expect to write it as a byproduct of your project.
The idea I have is to expose an interface for plugins to describe command line options they want to receive. I have attached a prototype header. From this interface, wget will have a list of command line options to support, along with plugin function to be called for handling plugin specific options. In addition to using this to parse command line, wget can Use the descriptions and category information provided to generate --help output.
First let me ask you, how exactly do you envision a user using plugins with Wget2? How are plugins selected? How does the user even know if a plugin exists?
Regarding the need to support plugin side addition of command line options at the first place, here are my thoughts. Plugins might need additional data from the user. I can think of 3 ways in which it can be done: 1. Environment variables. 2. Files with well-known names. 3. Command line. Environment variables have a disadvantage that they are automatically passed to the subprocesses, creating a chance for interference. Also, name clashes cannot be discovered. Using files with well-known names has a chance of interference with parallel running instances of wget. None of these disadvantages are shared with using command line options.
However, all three are commonly used to provide options to a program and should all always be supported. Environment variables allow for all instances in one subshell to share a set of commands without having to pass them multiple times and without interfering with instances in other subshells Configuration files are useful so the system administrator can set a bunch of common options for all users, maybe to enforce a policy. Command line options give the user the power to modify options on a per invokation level.
Opinions are welcome. Regards, Akash Rawal.
-- Thanking You, Darshit Shah PGP Fingerprint: 7845 120B 07CB D8D6 ECE5 FF2B 2A17 43ED A91A 35B6
signature.asc
Description: PGP signature