in reply to What's the connection between the CPAN programming methods to what happens in the CPAN shell?
What's the underlying model here?
You have to consider the full CPAN object model. Ultimately, actions all fall to a CPAN::Distribution object and "force" is just a method that sets a flag and invokes other methods. The shell is a CPAN::Shell object that converts your commands to actions upon the appropriate objects.
For example, installing a module means creating a module object, finding the distribution object that corresponds to it, and then installing the distribution. (Well, that's the short version anyway.)
Here's a modified excerpt of what I use in Perl::Dist as part of building Vanilla Perl. (Warning: Perl::Dist as a whole sucks and needs to be rewritten; but using snippets is OK.)
print "Preparing to install $name from CPAN\n"; $obj = CPAN::Shell->expandany( $name ) or die "CPAN.pm couldn't locate $name"; if ( $obj->uptodate ) { print "$name is up to date\n"; exit } if ( $force ) { $obj->force("install"); $obj->uptodate or die "Forced installation of $name appears to have failed"; } else { $obj->install; $obj->uptodate or die "Installation of $name appears to have failed"; }
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
|
|---|