Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 72 lines (59 sloc) 1.652 kB
#!/usr/bin/env php
<?php
echo "\n";
$path = './...';
$args = array_merge(array(
'no-confirmation' => false,
), parseArgs($argv));
if (isset($args[0])) {
$path = $args[0];
}
$files = array_filter(explode("\n", `p4 diff -se $path`));
if (count($files) == 0) {
die("no files to open");
}
if (!$args['no-confirmation']) {
$f = fopen('php://stdin', 'r');
echo "Files to open: \n\t";
echo implode("\n\t", $files) . "\n";
echo "OK to add? (y/n): ";
if (trim(fgets($f)) != 'y') {
die("Aborted");
}
}
$filesList = implode(' ', $files);
$ret = `p4 edit $filesList`;
die($ret);
// ================
// HELPER FUNCTIONS
// ================
function parseArgs($argv){
array_shift($argv);
$out = array();
foreach ($argv as $arg){
if (substr($arg,0,2) == '--'){
$eqPos = strpos($arg,'=');
if ($eqPos === false){
$key = substr($arg,2);
$out[$key] = isset($out[$key]) ? $out[$key] : true;
} else {
$key = substr($arg,2,$eqPos-2);
$out[$key] = substr($arg,$eqPos+1);
}
} else if (substr($arg,0,1) == '-'){
if (substr($arg,2,1) == '='){
$key = substr($arg,1,1);
$out[$key] = substr($arg,3);
} else {
$chars = str_split(substr($arg,1));
foreach ($chars as $char){
$key = $char;
$out[$key] = isset($out[$key]) ? $out[$key] : true;
}
}
} else {
$out[] = $arg;
}
}
return $out;
}
Jump to Line
Something went wrong with that request. Please try again.