Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracting POD synopsis from FatPacked modules #7

Merged
merged 3 commits into from
Nov 24, 2017

Conversation

kiwiroy
Copy link
Collaborator

@kiwiroy kiwiroy commented Nov 21, 2017

I'm considering fatpacking some applify scripts and have found that when using something akin to the included code. The _print_help doesn't when the script is fatpacked for the script list -help as $INC{'App/Command/List.pm'} is a FatPacked::HASH that cannot be opened. script -help is functional fatpacked, as is script list -help in un-fatpacked form.

documentation __FILE__;
subcommand list => 'list all possible outcomes' => sub {
  documentation 'App::Command::List';
};

This appears to fix it but needs improvement and tests for which I'm at a loss on how to construct.

Copy link
Owner

@jhthorsen jhthorsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the change, but I would very much like an unit test. Don't think it should be too hard to extend https://github.com/jhthorsen/applify/blob/master/t/help.t ..?

lib/Applify.pm Outdated
@@ -350,6 +350,16 @@ sub _print_synopsis {
unless (-e $documentation) {
eval "use $documentation; 1" or die "Could not load $documentation: $@";
$documentation =~ s!::!/!g;
# might be FatPacked $INC{"$documentation.pm"}{"$documentation.pm"}
if (ref($INC{"$documentation.pm"})) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about if (ref $INC{"$documentation.pm"} eq 'HASH') ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know a lot more about require now. The %INC entry is a FatPacked object that must have an INC method which returns a readable filehandle.

@jhthorsen
Copy link
Owner

jhthorsen commented Nov 24, 2017

Merge when you feel like it 👍

@kiwiroy kiwiroy merged commit 8d2f866 into jhthorsen:master Nov 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants