Skip Menu |

This queue is for tickets about the Getopt-Euclid CPAN distribution.

Report information
The Basics
Id: 61438
Status: resolved
Priority: 0/
Queue: Getopt-Euclid

People
Owner: Nobody in particular
Requestors: paolo [...] medeo.net
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 0.0.2
  • 0.0.3
  • 0.0.4
  • 0.2.1
  • v0.0.5
  • v0.0.7
  • v0.0.8
  • v0.0.9
  • v0.1.0
  • v0.2.0
  • v0.2.2
  • v0.2.3
Fixed in: (no value)



Subject: Need the possibility of distinguishing between option not used or used without optional argument - added field 'no_val'
Kevin, You rightfully rejected my filing this issue as a bug, since the original specs of the module called for (to me illogical) having the same default value applied both when an option is not used or it is used without any optional argument. As you can see from the attached file, I have solved the issue by creating a new field ('no_val') for specifying the value to assign to the option when it is called without arguments. Here following is an example of how the POD would look like: =item [-]-debug [<log_level>] Debug: optional log level. If no log level is specified, it is assumed to be 'DEBUG' =for Euclid: log_level.type: string log_level.default: 'NOT SET' log_level.no_val: 'DEBUG' I have tested the code with a couple of scripts and seems performing fine. I'll test even more early next week. Thanks! Paolo
Subject: Euclid.pm
Hi, I'm unable to download your modified Euclid.pm. Can you please re-attach it? Thanks, -Kevin
From: paolo [...] medeo.net
Hi Kevin, Here it is. I've sent it also to your private e-mail account. Thanks! Paolo On Thu Sep 23 14:32:34 2010, kgalinsky wrote: Show quoted text
> Hi, > > I'm unable to download your modified Euclid.pm. Can you please
re-attach it? Show quoted text
> > Thanks, > -Kevin
Subject: Euclid.pm

Message body is not shown because it is too large.

From: paolo [...] medeo.net
Is anybody alive? I've provided a fix to a design shortcoming that was indispensable for me (and, I guess others), with the understanding that this would be soon implemented in the new release of this module. Since we agreed on the interface, I went ahead adopting my implementation while waiting for the official release. Over eight months have passed without any progress. Some time ago I've learned from Kevin that he has handed everything to somebody else supposedly more active with bug-fixing and code improvements. However, the page shows Kevin still as the curator and no mention of the new person: What is going on? Paolo On Fri Sep 17 17:36:32 2010, pamedeo wrote: Show quoted text
> Kevin, > You rightfully rejected my filing this issue as a bug, since the > original specs of the module called for (to me illogical) having the > same default value applied both when an option is not used or it is used > without any optional argument. > As you can see from the attached file, I have solved the issue by > creating a new field ('no_val') for specifying the value to assign to > the option when it is called without arguments. > Here following is an example of how the POD would look like: > > =item [-]-debug [<log_level>] > > Debug: optional log level. If no log level is specified, it is assumed > to be 'DEBUG' > > =for Euclid: > log_level.type: string > log_level.default: 'NOT SET' > log_level.no_val: 'DEBUG' > > I have tested the code with a couple of scripts and seems performing > fine. I'll test even more early next week. > > Thanks! > > Paolo
From: paolo [...] medeo.net
Hi Florent, I've inserted the code changes to the new version Euclid.pm (see attached file) to support the new 'no_val' field to disambiguate between the case when an option is used without an optional argument and the case when it is not used. This code change had been already accepted by Kevin, and we were in agreement that he would insert in his release 0.2.4 I have tested my changes in the new code and they appear to function correctly. I have already a lot of code that relies on that disambiguation and hate to be stuck with my branch of Getopt::Euclid missing out your improvements, or having to create yet another flavor of Getopt. I really hope that you can quickly review and incorporate my code changes. They are mostly in portion of codes that haven't changed much in the past few releases. Thanks! Paolo On Fri Sep 17 17:36:32 2010, pamedeo wrote: Show quoted text
> Kevin, > You rightfully rejected my filing this issue as a bug, since the > original specs of the module called for (to me illogical) having the > same default value applied both when an option is not used or it is used > without any optional argument. > As you can see from the attached file, I have solved the issue by > creating a new field ('no_val') for specifying the value to assign to > the option when it is called without arguments. > Here following is an example of how the POD would look like: > > =item [-]-debug [<log_level>] > > Debug: optional log level. If no log level is specified, it is assumed > to be 'DEBUG' > > =for Euclid: > log_level.type: string > log_level.default: 'NOT SET' > log_level.no_val: 'DEBUG' > > I have tested the code with a couple of scripts and seems performing > fine. I'll test even more early next week. > > Thanks! > > Paolo
Subject: Euclid.pm

Message body is not shown because it is too large.

Hi Paolo, My time being limited, I appreciate that you submitted a patched version of Getopt::Euclid. I am afraid that Kevin never got the time to properly finish what he was up to with Getopt::Euclid and that's why your patch never made it in the codebase so far. Note that Kevin set up a Git repository for Getopt::Euclid (see http://sourceforge.net/scm/?type=git&group_id=259291), so for any future hacking of Getopt::Euclid, use this git repository and it will make our life easier. Also, there is a series of tests (in the ./t/ folder) that Getopt::Euclid uses to limit the risk of bugs. So, ideally, when you submit code, you should submit new tests and make sure that the old tests still pass successfully. Now, regarding this option that you suggest... To be honest, I am not sure that I like it the way it is because there is never the need to have both a "strong" default like log_level.default: 'NOT SET' and a "weak" default like log_level.no_val: 'DEBUG' at the same time. But how about keeping the general idea but specifying the following way? =item [-]-debug [<log_level>] Debug: optional log level. If no log level is specified, it is assumed to be 'DEBUG' =for Euclid: log_level.type: string log_level.default: 'DEBUG' log_level.default.is_strong: 0 And, of course, the default would be to have strong default, i.e. log_level.default.is_strong of 1, to keep the compatibility with previous versions of Getopt::Euclid. Florent
My proposal would makes it possible to display the default value in the POD as is already possible in recent versions of Getopt::Euclid. =item [-]-debug [<log_level>] Debug: optional log level. If no log level is specified, it is assumed to be [default: log_level.default] =for Euclid: log_level.type: string log_level.default: 'DEBUG' log_level.default.is_strong: 0
From: paolo [...] medeo.net
Thanks, Florent for the quick reply. Honestly, I'm a bit confused, since I haven't found anywhere in the documentation and current release anything about 'is_strong' modifier. What would it do? Would it undef the variable associated with the option in the case the option is not used? What I need is to distinguish between not using an option and using without the optional argument (e.g. --verbose writing to STDOUT if no argument is used or writing to a file whose name is provided as argument: definitely you want the program to shut up if you don't use --verbose). At the same time, it is necessary to respect the backward compatibility (i.e. the option with optional argument set to the default value both when it is not used or when it is used without arguments--useless behavior, in my opinion), we need not to alter any behavior of the existing fields. I have achieved that by introducing the 'no_val' field. I thought that the meaning would be intuitive, and--definitely--the implementation in the code is quite easy. As matter of fact am using it successfully in our code and have never encountered any issue with any other script using Getopt::Euclid. Unfortunately, I do have a full-time job and am quite busy on the side as well. I'm not interested in any way to become one of the developers of this module. I thought that providing an implementation of the possible solution in a way that could be easily "diffed" with the latest development draft (I believe that I've introduced changes in maximum ten lines of code) would be a good step forward compared to just whining about a bug. Since the solution to our problems has been already implemented internally, I have serious doubt that my boss would authorize me spending more efforts and resources for this module. If I have to do it in my "free time", I'll probably could think messing with the Git repository and working on some test, but it will take much longer. Thanks! Paolo On Wed Aug 31 00:52:06 2011, FANGLY wrote: Show quoted text
> My proposal would makes it possible to display the default value in the > POD as is already possible in recent versions of Getopt::Euclid. > > =item [-]-debug [<log_level>] > > Debug: optional log level. If no log level is specified, it is assumed > to be [default: log_level.default] > > =for Euclid: > log_level.type: string > log_level.default: 'DEBUG' > log_level.default.is_strong: 0
Hi Paolo, Your initial example got me confused but I think I understand what you are after now. Indeed, there is no reason why a parameter could not have both a regular default and the type of default that you suggest, which I suggest to call an optional default (opt_default) or weak default (weak_default). I'll try and merge your changes soon. Florent
From: paolo [...] medeo.net
Thanks, Florent! I appreciate it, and I'll stay tuned. Paolo
Ok Paolo, thanks again for the patch! I managed to merge it but I called the constraint opt_default instead of no_val, as discussed above. The patch initially made fail some tests but I managed to fix that without too much trouble. I also added some safeguards and tests. Check it out. Version 0.2.8