Page MenuHomePhabricator

D19744.diff
No OneTemporary

D19744.diff

diff --git a/src/applications/transactions/bulk/management/PhabricatorBulkManagementExportWorkflow.php b/src/applications/transactions/bulk/management/PhabricatorBulkManagementExportWorkflow.php
--- a/src/applications/transactions/bulk/management/PhabricatorBulkManagementExportWorkflow.php
+++ b/src/applications/transactions/bulk/management/PhabricatorBulkManagementExportWorkflow.php
@@ -77,14 +77,27 @@
$is_overwrite = $args->getArg('overwrite');
$output_path = $args->getArg('output');
- if (!strlen($output_path) && $is_overwrite) {
+ if (!strlen($output_path)) {
throw new PhutilArgumentUsageException(
pht(
- 'Flag "--overwrite" has no effect without "--output".'));
+ 'Use "--output <path>" to specify an output file, or "--output -" '.
+ 'to print to stdout.'));
+ }
+
+ if ($output_path === '-') {
+ $is_stdout = true;
+ } else {
+ $is_stdout = false;
+ }
+
+ if ($is_stdout && $is_overwrite) {
+ throw new PhutilArgumentUsageException(
+ pht(
+ 'Flag "--overwrite" has no effect when outputting to stdout.'));
}
if (!$is_overwrite) {
- if (Filesystem::pathExists($output_path)) {
+ if (!$is_stdout && Filesystem::pathExists($output_path)) {
throw new PhutilArgumentUsageException(
pht(
'Output path already exists. Use "--overwrite" to overwrite '.
@@ -113,7 +126,7 @@
$iterator = $file->getFileDataIterator();
- if (strlen($output_path)) {
+ if (!$is_stdout) {
// Empty the file before we start writing to it. Otherwise, "--overwrite"
// will really mean "--append".
Filesystem::writeFile($output_path, '');
@@ -121,6 +134,12 @@
foreach ($iterator as $chunk) {
Filesystem::appendFile($output_path, $chunk);
}
+
+ echo tsprintf(
+ "%s\n",
+ pht(
+ 'Exported data to "%s".',
+ Filesystem::readablePath($output_path)));
} else {
foreach ($iterator as $chunk) {
echo $chunk;

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 27, 7:13 AM (21 h, 25 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6792494
Default Alt Text
D19744.diff (2 KB)

Event Timeline