Skip to content

Commit

Permalink
Merge pull request #17 from geneanet/feature/no-timestamp-option
Browse files Browse the repository at this point in the history
Add a no-timestamp option
  • Loading branch information
treyhyde committed Jan 20, 2016
2 parents 8fdd8f1 + e06f449 commit b016599
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ protected function configure()
InputOption::VALUE_NONE,
'generate @@protoc insertion points'
)
->addOption(
'no-timestamp',
null,
InputOption::VALUE_NONE,
'do not generate a timestamp comment'
)
->addOption(
'define',
'D',
Expand Down Expand Up @@ -183,6 +189,9 @@ protected function executeProtoc(InputInterface $input, OutputInterface $output)
if ($input->getOption('insertions')) {
$args['options']['insertions'] = 1;
}
if ($input->getOption('no-timestamp')) {
$args['options']['no-timestamp'] = 1;
}

$cmd[] = '--php_out=' .
escapeshellarg(
Expand Down Expand Up @@ -272,4 +281,4 @@ protected function executeCompile(InputInterface $input, OutputInterface $output
return 255;
}
}
}
}
6 changes: 4 additions & 2 deletions library/DrSlump/Protobuf/Compiler/JsonGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ protected function buildFile(proto\FileDescriptorProto $proto, $fname, $contents
$s = array();
$s[]= "// DO NOT EDIT! Generated by Protobuf-PHP protoc plugin " . Protobuf::VERSION;
$s[]= "// Source: " . $proto->getName();
$s[]= "// Date: " . gmdate('Y-m-d H:i:s');
if (!$this->option('no-timestamp', false)) {
$s[]= "// Date: " . gmdate('Y-m-d H:i:s');
}
$s[]= "";
$s[]= "// @@protoc_insertion_point(scope_file)";
$s[]= "";
Expand Down Expand Up @@ -437,4 +439,4 @@ protected function normalizeNS($package)

return $namespace;
}
}
}
4 changes: 3 additions & 1 deletion library/DrSlump/Protobuf/Compiler/PhpGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ protected function buildFile(proto\FileDescriptorProto $proto, $fname, $contents
$s[]= "<?php";
$s[]= "// DO NOT EDIT! Generated by Protobuf-PHP protoc plugin " . Protobuf\Protobuf::VERSION;
$s[]= "// Source: " . $proto->getName();
$s[]= "// Date: " . date('Y-m-d H:i:s');
if (!$this->option('no-timestamp', false)) {
$s[]= "// Date: " . date('Y-m-d H:i:s');
}
$s[]= "";
$s[]= "// @@protoc_insertion_point(scope_file)";
$s[]= "";
Expand Down
8 changes: 4 additions & 4 deletions library/DrSlump/Protobuf/Compiler/templates/php-file.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
$data - A string with the generated source for the entities in the proto
*/ ?>
<?php echo "<?php"?>
<?php echo "<?php"?>
// DO NOT EDIT! Generated by Protobuf-PHP protoc plugin <?php echo \DrSlump\Protobuf\Protobuf::VERSION?>
// Source: <?php echo $this->proto->name?>
<?php if ($this->option('timestamp', true)): ?>
// Date: <?php echo gmdate('Y-m-d H:i:s')?>
// Source: <?php echo $this->proto->name?>
<?php if (!$this->option('no-timestamp', false)): ?>
// Date: <?php echo gmdate('Y-m-d H:i:s')?>
<?php endif; ?>

<?php if ($this->option('insertions')): ?>
Expand Down

0 comments on commit b016599

Please sign in to comment.