Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: toddr [...] cpanel.net
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: v0.2.0
Fixed in: (no value)



Subject: defaults should be able to leverage $ENV
Hi, I've committed some perl evil to get Euclid to allow defaulting to environment variables. I do it like this: =item -core <core> directory where core path is. =for Euclid: core.default: "@{[$ENV{CORE}]}" core.type: /^\/\w\w\w/ The intention here is to set core's path to $ENV{CORE} if it's not supplied. There are 2 issues with my current approach. 1. Non-intuitive errors occur when -core is not fed on command line and $ENV{CORE} is not defined 2. even if -core is fed on the command line and $ENV{CORE} is not defined, I get an error complaining that -core was fed an invalid regex. the regex for default seems to be parsing the default even if default is not used. It seems like there should be a better approach to this problem and it seems like this is a feature many would desire. How about something like this that would be checked if it is not defined on command line, before going to core.default? =for Euclid: core.env_var_default: CORE core.type: /^\/\w\w\w/
Hi Todd, How about this? =item -core <core> Directory where core can be found =for Euclid: core.default: $ENV{CORE} || '' If the CORE environment variable is set, then the default is the value of CORE. If CORE is not set, then the default is the empty string ''. Florent
On Sat Sep 03 02:11:42 2011, FANGLY wrote: Show quoted text
> Hi Todd, > > How about this? > > =item -core <core> > > Directory where core can be found > > =for Euclid: > core.default: $ENV{CORE} || '' > > If the CORE environment variable is set, then the default is the value > of CORE. If CORE is not set, then the default is the empty string ''. > > Florent
Yes, that's exactly what I was thinking.