#! /usr/bin/env php
<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

// Check if we're running directly from git repo or if we're running
// from a PEAR packaged version.
$path = '@php-dir@';
if ($path[0] === '@') {
    // Git repo needs to set the include path as the pinentry program is not
    // invoked in the current directory.
    $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..';
} else {
    // PEAR packaged version needs to set include path in case it is running
    // in a local PEAR tree that's not in the system PHP include path.
}

// Workaround for composer installs (#19914)
$composerDir = $path . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Console_CommandLine';
if (is_dir($composerDir)) {
    $path .= PATH_SEPARATOR . $composerDir;
}

// We depend on Console_CommandLine, so we append also the default include path
set_include_path($path . PATH_SEPARATOR . get_include_path());

require_once 'Crypt/GPG/PinEntry.php';

$pinentry = new Crypt_GPG_PinEntry();
$pinentry->__invoke();

?>
