Page MenuHomePhabricator

D21203.id50487.diff
No OneTemporary

D21203.id50487.diff

diff --git a/src/ref/paste/ArcanistPasteRef.php b/src/ref/paste/ArcanistPasteRef.php
--- a/src/ref/paste/ArcanistPasteRef.php
+++ b/src/ref/paste/ArcanistPasteRef.php
@@ -30,7 +30,13 @@
}
public function getURI() {
- return idxv($this->parameters, array('fields', 'uri'));
+ $uri = idxv($this->parameters, array('fields', 'uri'));
+
+ if ($uri === null) {
+ $uri = '/'.$this->getMonogram();
+ }
+
+ return $uri;
}
public function getContent() {
diff --git a/src/workflow/ArcanistPasteWorkflow.php b/src/workflow/ArcanistPasteWorkflow.php
--- a/src/workflow/ArcanistPasteWorkflow.php
+++ b/src/workflow/ArcanistPasteWorkflow.php
@@ -9,10 +9,11 @@
public function getWorkflowInformation() {
$help = pht(<<<EOTEXT
-Share and grab text using the Paste application. To create a paste,
-use stdin to provide the text:
+Share and grab text using the Paste application. To create a paste, use the
+"--input" flag or provide the text on stdin:
$ cat list_of_ducks.txt | arc paste
+ $ arc paste --input list_of_ducks.txt
To retrieve a paste, specify the paste ID:
@@ -34,8 +35,12 @@
$this->newWorkflowArgument('lang')
->setParameter('language')
->setHelp(pht('Language for the paste.')),
- $this->newWorkflowArgument('json')
- ->setHelp(pht('Output in JSON format.')),
+ $this->newWorkflowArgument('input')
+ ->setParameter('path')
+ ->setIsPathArgument(true)
+ ->setHelp(pht('Create a paste using the content in a file.')),
+ $this->newWorkflowArgument('browse')
+ ->setHelp(pht('After creating a paste, open it in a web browser.')),
$this->newWorkflowArgument('argv')
->setWildcard(true),
);
@@ -44,6 +49,8 @@
public function runWorkflow() {
$set_language = $this->getArgument('lang');
$set_title = $this->getArgument('title');
+ $is_browse = $this->getArgument('browse');
+ $input_path = $this->getArgument('input');
$argv = $this->getArgument('argv');
if (count($argv) > 1) {
@@ -52,6 +59,8 @@
'Specify only one paste to retrieve.'));
}
+ $is_read = (count($argv) === 1);
+
$symbols = $this->getSymbolEngine();
if (count($argv) === 1) {
@@ -67,6 +76,19 @@
'Flag "--title" is not supported when reading pastes.'));
}
+ if ($is_browse) {
+ throw new PhutilArgumentUsageException(
+ pht(
+ 'Flag "--browse" is not supported when reading pastes. Use '.
+ '"arc browse" to browse known objects.'));
+ }
+
+ if ($input_path !== null) {
+ throw new PhutilArgumentUsageException(
+ pht(
+ 'Flag "--input" is not supported when reading pastes.'));
+ }
+
$paste_symbol = $argv[0];
$paste_ref = $symbols->loadPasteForSymbol($paste_symbol);
@@ -74,7 +96,8 @@
throw new PhutilArgumentUsageException(
pht(
'Paste "%s" does not exist, or you do not have access '.
- 'to see it.'));
+ 'to see it.',
+ $paste_symbol));
}
echo $paste_ref->getContent();
@@ -82,7 +105,11 @@
return 0;
}
- $content = $this->readStdin();
+ if ($input_path === null || $input_path === '-') {
+ $content = $this->readStdin();
+ } else {
+ $content = Filesystem::readFile($input_path);
+ }
$xactions = array();
@@ -121,6 +148,9 @@
$paste_phid = idxv($result, array('object', 'phid'));
$paste_ref = $symbols->loadPasteForSymbol($paste_phid);
+ $uri = $paste_ref->getURI();
+ $uri = $this->getAbsoluteURI($uri);
+
$log = $this->getLogEngine();
$log->writeSuccess(
@@ -130,7 +160,11 @@
echo tsprintf(
'%s',
$paste_ref->newDisplayRef()
- ->setURI($paste_ref->getURI()));
+ ->setURI($uri));
+
+ if ($is_browse) {
+ $this->openURIsInBrowser(array($uri));
+ }
return 0;
}

File Metadata

Mime Type
text/plain
Expires
Sun, Apr 27, 2:20 AM (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7385459
Default Alt Text
D21203.id50487.diff (3 KB)

Event Timeline