Skip Menu |

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

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

People
Owner: Nobody in particular
Requestors: zdm [...] softvisio.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Small improvement for extending Getopt::Euclid usage
Date: Sun, 4 Aug 2013 20:11:54 +0300
To: bug-getopt-euclid [...] rt.cpan.org
From: zdm <zdm [...] softvisio.net>
Please, make $man variable declaration package scoped (our instead of my), so we can manipulate it from outside Getopt::Euclid namespace. We trying to integrate Euclid to our application framework and this is needed for manually pass list of pod files to Getopt::Euclid parser. Thanks a lot!
Hi, Could you please give me a bit more background, and possibly code for what you are trying to achieve. I would like to make sure that making $man global is indeed the best option for your use-case. Best, Florent On Sun Aug 04 13:12:27 2013, zdm@softvisio.net wrote: Show quoted text
> Please, make $man variable declaration package scoped (our instead of my), > so we can manipulate it from outside Getopt::Euclid namespace. > We trying to integrate Euclid to our application framework and this is > needed for manually pass list of pod files to Getopt::Euclid parser. > > Thanks a lot!
Subject: Re: [rt.cpan.org #87592] Small improvement for extending Getopt::Euclid usage
Date: Mon, 5 Aug 2013 04:13:26 +0300
To: bug-Getopt-Euclid [...] rt.cpan.org
From: zdm <zdm [...] softvisio.net>
Hi, We use following code: require Getopt::Euclid; # @PACKAGES array contains list of packages names for parsing, here we must have possibility to access $man: $Getopt::Euclid::man = &Getopt::Euclid::_extract_pod($CO->{PROCESS}->{SCRIPT_PATH} . '/' . $CO->{PROCESS}->{SCRIPT_NAME}, map { $INC{ $_ =~ s/::/\//gr . '.pm' } } reverse @PACKAGES); Getopt::Euclid->process_args(\@ARGV); &Getopt::Euclid::_minimize_entries_of(\%ARGV); #always use :minimal_keys On Mon, Aug 5, 2013 at 4:01 AM, Florent Angly via RT < bug-Getopt-Euclid@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=87592 > > > Hi, > > Could you please give me a bit more background, and possibly code for what > you are trying to achieve. I would like to make sure that making $man > global is indeed the best option for your use-case. > Best, > > Florent > > On Sun Aug 04 13:12:27 2013, zdm@softvisio.net wrote:
> > Please, make $man variable declaration package scoped (our instead of
> my),
> > so we can manipulate it from outside Getopt::Euclid namespace. > > We trying to integrate Euclid to our application framework and this is > > needed for manually pass list of pod files to Getopt::Euclid parser. > > > > Thanks a lot!
> > > >
A couple of points. For portability, it is good practice to replace: $CO->{PROCESS}->{SCRIPT_PATH} . '/' . $CO->{PROCESS}->{SCRIPT_NAME} by: File::Spec->catfile( $CO->{PROCESS}->{SCRIPT_PATH} . '/' . $CO->{PROCESS}->{SCRIPT_NAME} ) It is also very discouraged for you to use private methods of Getopt::Euclid, like _extract_pod _minimize_entries_of The preceding '_' is an indication of their internal status and, as such, they are not described in the documentation. Their input, output or name could change any time without warning because they are not for public consumption. In fact they _have_ changed in the recent past. Now considering your main issue. Have you read this section of the documentation? http://search.cpan.org/~fangly/Getopt-Euclid-0.4.3/lib/Getopt/Euclid.pm#Module_Interface It describes how Getopt::Euclid can parse the POD of any requested module. It sounds like this is what you are trying to achieve...
On Mon Aug 05 00:37:03 2013, FANGLY wrote: Show quoted text
> A couple of points. For portability, it is good practice to replace: > $CO->{PROCESS}->{SCRIPT_PATH} . '/' . $CO->{PROCESS}->{SCRIPT_NAME} > by: > File::Spec->catfile( $CO->{PROCESS}->{SCRIPT_PATH} . '/' . $CO-
> >{PROCESS}->{SCRIPT_NAME} )
Here, I meant: File::Spec->catfile( $CO->{PROCESS}->{SCRIPT_PATH}, $CO->{PROCESS}->{SCRIPT_NAME} )
Subject: Re: [rt.cpan.org #87592] Small improvement for extending Getopt::Euclid usage
Date: Mon, 5 Aug 2013 18:48:52 +0300
To: bug-Getopt-Euclid [...] rt.cpan.org
From: zdm <zdm [...] softvisio.net>
Hello. Currently Euclid has no public interface, that allow manually define list of file for parsing. Default functionality is not suitable for us, because we want manage CLI interfaces centralized from one point, not write use Getopt::Euclid in every needed package. Second reason is that Euclid installs own import function - this produce conflicts with our packages code. It would be nice if you implement this functionality, so we don't have to call private methods. Or simply write our $man; )) Thanks for replies, have a nice day. On Mon, Aug 5, 2013 at 7:37 AM, Florent Angly via RT < bug-Getopt-Euclid@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=87592 > > > A couple of points. For portability, it is good practice to replace: > $CO->{PROCESS}->{SCRIPT_PATH} . '/' . $CO->{PROCESS}->{SCRIPT_NAME} > by: > File::Spec->catfile( $CO->{PROCESS}->{SCRIPT_PATH} . '/' . > $CO->{PROCESS}->{SCRIPT_NAME} ) > > It is also very discouraged for you to use private methods of > Getopt::Euclid, like > _extract_pod > _minimize_entries_of > The preceding '_' is an indication of their internal status and, as such, > they are not described in the documentation. Their input, output or name > could change any time without warning because they are not for public > consumption. In fact they _have_ changed in the recent past. > > Now considering your main issue. Have you read this section of the > documentation? > http://search.cpan.org/~fangly/Getopt-Euclid-0.4.3/lib/Getopt/Euclid.pm#Module_Interface > It describes how Getopt::Euclid can parse the POD of any requested module. > It sounds like this is what you are trying to achieve... > > >
Subject: Re: [rt.cpan.org #87592] Small improvement for extending Getopt::Euclid usage
Date: Mon, 5 Aug 2013 21:12:25 +0300
To: bug-Getopt-Euclid [...] rt.cpan.org
From: zdm <zdm [...] softvisio.net>
Also it would be nice to have a configurable option, that instruct euclid do not use pod file instead of pm, if pod with same name was found in same directory. On Mon, Aug 5, 2013 at 7:52 AM, Florent Angly via RT < bug-Getopt-Euclid@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=87592 > > > On Mon Aug 05 00:37:03 2013, FANGLY wrote:
> > A couple of points. For portability, it is good practice to replace: > > $CO->{PROCESS}->{SCRIPT_PATH} . '/' . $CO->{PROCESS}->{SCRIPT_NAME} > > by: > > File::Spec->catfile( $CO->{PROCESS}->{SCRIPT_PATH} . '/' . $CO-
> > >{PROCESS}->{SCRIPT_NAME} )
> > Here, I meant: > File::Spec->catfile( $CO->{PROCESS}->{SCRIPT_PATH}, > $CO->{PROCESS}->{SCRIPT_NAME} ) >
Subject: Re: [rt.cpan.org #87592] Small improvement for extending Getopt::Euclid usage
Date: Wed, 7 Aug 2013 15:17:21 +0300
To: bug-Getopt-Euclid [...] rt.cpan.org
From: zdm <zdm [...] softvisio.net>
What is your decision? On Mon, Aug 5, 2013 at 7:52 AM, Florent Angly via RT < bug-Getopt-Euclid@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=87592 > > > On Mon Aug 05 00:37:03 2013, FANGLY wrote:
> > A couple of points. For portability, it is good practice to replace: > > $CO->{PROCESS}->{SCRIPT_PATH} . '/' . $CO->{PROCESS}->{SCRIPT_NAME} > > by: > > File::Spec->catfile( $CO->{PROCESS}->{SCRIPT_PATH} . '/' . $CO-
> > >{PROCESS}->{SCRIPT_NAME} )
> > Here, I meant: > File::Spec->catfile( $CO->{PROCESS}->{SCRIPT_PATH}, > $CO->{PROCESS}->{SCRIPT_NAME} ) >
It sounds like you are trying to do more than what Getopt::Euclid was designed to do. Show quoted text
> Currently Euclid has no public interface, that allow manually define > list of file for parsing. Default functionality is not suitable for us, > because we want manage CLI interfaces centralized from one point, not write > use Getopt::Euclid in every needed package.
Did you try what I suggested earlier (from the manual)? use Module1::Getopt (); # No argument parsing use Module2::Getopt (); # No argument parsing use Getopt::Euclid; # Arguments parsed This means that you can put the declaration of some common arguments in Module1::Getopt and Module2::Getopt and reuse it in every module that needs it. I do not fully understand what you are trying to achieve, so that may or may not be an viable option for you. Show quoted text
> Second reason is that Euclid installs own import function - this > produce conflicts with our packages code.
You can call Getopt::Euclid this way to avoid it importing: use Getopt::Euclid (); Again, that or may not be what you want. Show quoted text
> It would be nice if you implement this functionality, so we don't have > to call private methods.
I am open to making some methods publicly available wherever that makes sense. Show quoted text
> Or simply write our $man; ))
By the way, I wanted to clarify that I cannot make $man global, because that would imply that if several scripts that use Getopt::Euclid were executed run simultaneously, they would overwrite each other's $man. I suggest the following course of action. Clone the git development branch (0.2.x) of Getopt::Euclid (http://sourceforge.net/p/getopt-euclid/code/ci/0.2.x/tree/) and try to code the features you need. It may also make sense to developing a new module that does exactly what you need. Feel free to have Getopt::Euclid as a dependency and use some of the internal methods if it makes sense. As mentioned above, I am open to making some internal methods publicly available, or even expose new ones if required. Cheers, Florent
Subject: Re: [rt.cpan.org #87592] Small improvement for extending Getopt::Euclid usage
Date: Thu, 8 Aug 2013 10:09:13 +0300
To: bug-Getopt-Euclid [...] rt.cpan.org
From: zdm <zdm [...] softvisio.net>
On Thu, Aug 8, 2013 at 2:15 AM, Florent Angly via RT < bug-Getopt-Euclid@rt.cpan.org> wrote: Show quoted text
> > Or simply write our $man; ))
> > By the way, I wanted to clarify that I cannot make $man global, because > that would imply that if several scripts that use Getopt::Euclid were > executed run simultaneously, they would overwrite each other's $man.
This is not true. $man variable stay the same in both cases. One difference is that in our case we can access it from outside euclid namespace, but this var will stay the same for every code, running simultaneously, and there are no differences for your code. Packages, that implement different CLI interfaces, may have other functionality and have own import methods, but, currently, we need to write use Getopt::Euclid in every such package, not Getopt::Euclid(), because in this way this package pod will not be parsed. Also, this is a bad idea to overwrite such often used function as import without fallback functionality if this function already exists. Even Exporter don't do this. Looking at your source code i can't understand the need of install import for simply add package name to @pod. Can you add this public method, named, for example, process_files, that allow to parse desired pods without need to use Getopt::Euclid in them and overwrite import: sub process_files { my @files = @_; $man = &_extract_pod( reverse @files ); return; } I think - our improvement request has sense and make euclid more flexible in usage. In any case, it will not affect for current functionality and compatibility. Thanks for support.
You are right about $man. Nothing prevents me from making it global. I have made this change (and others) on a new branch that you can test here: http://sourceforge.net/p/getopt-euclid/code/ci/topic_zdm/tree/ I am also considering having the man() method accept an argument instead of making $man global. I have modularized the code and created a public process_pod() method. I have added an option to check for .pod files or not since it seems like this is something you desire. I have added an example to the documentation: use Getopt::Euclid (); my @pods = ( 'script.pl', 'Module.pm' ); $Getopt::Eudlid::MAN = Getopt::Euclid->process_pods(\@pods, {-strict => 1}); my @args = ( '-in', 'file.txt', '-out', 'results.txt' ); Getopt::Euclid->process_args(\@args); See how this branch works for your intended use and give me feedback, please. Florent
Subject: Re: [rt.cpan.org #87592] Small improvement for extending Getopt::Euclid usage
Date: Fri, 16 Aug 2013 12:32:21 +0300
To: bug-Getopt-Euclid [...] rt.cpan.org
From: zdm <zdm [...] softvisio.net>
Hi! This is what we need! In your example there is a typo, you wrote Eudlid instead of Euclid. Strict option work as expected. This is not very important, but manipulate $MAN variable outside Euclid looks like a hack, i consider to make public method, as i write in previous post. Also i suggest to make process_args accept options, such as 'minimal_keys' etc... Getopt::Euclid->process_args(\@args, minimal_keys => 1);, so we don't need to call &Getopt::Euclid::_minimize_entries_of(\%ARGV); manually after process_args called. Thanks a lot. On Fri, Aug 16, 2013 at 8:09 AM, Florent Angly via RT < bug-Getopt-Euclid@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=87592 > > > You are right about $man. Nothing prevents me from making it global. I > have made this change (and others) on a new branch that you can test here: > http://sourceforge.net/p/getopt-euclid/code/ci/topic_zdm/tree/ > I am also considering having the man() method accept an argument instead > of making $man global. > > I have modularized the code and created a public process_pod() method. I > have added an option to check for .pod files or not since it seems like > this is something you desire. > > I have added an example to the documentation: > use Getopt::Euclid (); > my @pods = ( 'script.pl', 'Module.pm' ); > $Getopt::Eudlid::MAN = Getopt::Euclid->process_pods(\@pods, {-strict > => 1}); > my @args = ( '-in', 'file.txt', '-out', 'results.txt' ); > Getopt::Euclid->process_args(\@args); > > See how this branch works for your intended use and give me feedback, > please. > > Florent >
Subject: Re: [rt.cpan.org #87592] Small improvement for extending Getopt::Euclid usage
Date: Fri, 16 Aug 2013 13:13:32 +0300
To: bug-Getopt-Euclid [...] rt.cpan.org
From: zdm <zdm [...] softvisio.net>
Also, now process_pods can receive list of file names, so now we don't need to manipulate $MAN outside, just make process_pods always write it's result into $MAN instead of return them to caller. 115: -$MAN = Getopt::Euclid->process_pods( [reverse @pod_names] ); 115: +__PACKAGE__->process_pods( [reverse @pod_names] ); 171: -return $pod_string; 171: +$MAN = $pod_string; 172: +return; And $MAN don't need to be declared as 'our' now. That's all. Thanks for cooperation. On Fri, Aug 16, 2013 at 8:09 AM, Florent Angly via RT < bug-Getopt-Euclid@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=87592 > > > You are right about $man. Nothing prevents me from making it global. I > have made this change (and others) on a new branch that you can test here: > http://sourceforge.net/p/getopt-euclid/code/ci/topic_zdm/tree/ > I am also considering having the man() method accept an argument instead > of making $man global. > > I have modularized the code and created a public process_pod() method. I > have added an option to check for .pod files or not since it seems like > this is something you desire. > > I have added an example to the documentation: > use Getopt::Euclid (); > my @pods = ( 'script.pl', 'Module.pm' ); > $Getopt::Eudlid::MAN = Getopt::Euclid->process_pods(\@pods, {-strict > => 1}); > my @args = ( '-in', 'file.txt', '-out', 'results.txt' ); > Getopt::Euclid->process_args(\@args); > > See how this branch works for your intended use and give me feedback, > please. > > Florent >
Sounds good. I'm out of town for a couple of days, but I'll get back to you on this. Best, Florent
Alright. Have a look at the new changes on the branch and let me know what you think. If it looks good, then I'll release a new version of Getopt::Euclid.
Subject: Re: [rt.cpan.org #87592] Small improvement for extending Getopt::Euclid usage
Date: Tue, 20 Aug 2013 14:32:02 +0300
To: bug-Getopt-Euclid [...] rt.cpan.org
From: zdm <zdm [...] softvisio.net>
All tests passed. Thanks! On Tue, Aug 20, 2013 at 11:26 AM, Florent Angly via RT < bug-Getopt-Euclid@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=87592 > > > Alright. Have a look at the new changes on the branch and let me know what > you think. If it looks good, then I'll release a new version of > Getopt::Euclid. >
Version 0.4.4 uploaded. Thanks!