Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14097504
D19744.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D19744.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D19744: In "bin/bulk export", require "--output <path>" by default
Attached
Detach File
Event Timeline
Log In to Comment