Package DE_EPAGES::Core::API::Program::Base
Common OS-independend interface for 3rd party programs. Sub classes must implement the abstract methods command and version.
Example |
use MyProgram; # sub class of DE_EPAGES::Core::API::Program::Base $Program = MyProgram->new; say "MyProgram is installed" if $Program->isInstalled; say "Version=".$Program->version; system $MyProgram->command, '-v'; |
Functions
command
Returns the executable command. The result may or may not contain the full path name and extension. Note: the command may contain spaces - therefore use quotes where required. The method does not verify if the executable actually exists, has execute permissions or is included in the search path. Examples:
- perl
- perl.exe
- /usr/local/bin/perl
- C:\Program Files\Perl-5.16.0\bin\perl.exe
Syntax |
$Command = $Program->command; |
Example |
SystemCommand( [ $Program->command, '-e', 'print "1+2"' ] ); $Output = SystemCommand( '"'.$Program->command.'" -v', { Capture => 1 } ); |
Return |
|
installCmd
Returns the install command for program
Syntax |
my $Cmd = $Program->installCmd; |
Return |
|
isInstalled
checks if $Program is installed
Syntax |
$IsInstalled = $Program->isInstalled; |
Return |
|
isUpToDate
checks if $Program is up-to-date (not installed -> not up-to-date)
Syntax |
$Program->update unless $Program->isUpToDate; |
Return |
|
new
Creates a new program object.
Syntax |
$Program = SubClass->new; |
Example |
$Node = DE_EPAGES::Core::API::Program::nodejs->new; |
Return |
|
postInstall
runs code to be executed before installing/updating $Program
Syntax |
$Program->postInstall |
preInstall
runs code to be executed before installing/updating $Program
Syntax |
$Program->preInstall |
resource
Returns available URL and version of the product on the download site. If envvar EPAGES_REPO is set, prefer that URL (space-separated URL or absolute path).
Syntax |
($DownloadUrl, $DownloadVersion) = @{$Program->resource}; |
Return |
|
update
updates/installs $Program unless up-to-date
Syntax |
$Update = $Program->update; |
Return |
|
version
Returns the current version number executable command, typically in the format "0.0.0". Throws an error if the program is not installed or is not executable by the current user. Possible error codes are: CommandError|CommandFailed|NoVersionFound.
Syntax |
$Version = $Program->version; |
Example |
say "Version=".$Program->version; |
Return |
|
winpkg
Returns the current package name including suffix (e.g. .zip or .msi).
Syntax |
$Package = $Program->winpkg; |
Return |
|