Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15359581
D18987.id45538.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D18987.id45538.diff
View Options
diff --git a/bin/conduit b/bin/conduit
new file mode 120000
--- /dev/null
+++ b/bin/conduit
@@ -0,0 +1 @@
+../scripts/setup/manage_conduit.php
\ No newline at end of file
diff --git a/scripts/setup/manage_conduit.php b/scripts/setup/manage_conduit.php
new file mode 100755
--- /dev/null
+++ b/scripts/setup/manage_conduit.php
@@ -0,0 +1,21 @@
+#!/usr/bin/env php
+<?php
+
+$root = dirname(dirname(dirname(__FILE__)));
+require_once $root.'/scripts/init/init-script.php';
+
+$args = new PhutilArgumentParser($argv);
+$args->setTagline(pht('manage Conduit'));
+$args->setSynopsis(<<<EOSYNOPSIS
+**conduit** __command__ [__options__]
+ Manage Conduit.
+
+EOSYNOPSIS
+ );
+$args->parseStandardArguments();
+
+$workflows = id(new PhutilClassMapQuery())
+ ->setAncestorClass('PhabricatorConduitManagementWorkflow')
+ ->execute();
+$workflows[] = new PhutilHelpArgumentWorkflow();
+$args->parseWorkflows($workflows);
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2425,6 +2425,7 @@
'PhabricatorCommonPasswords' => 'applications/auth/constants/PhabricatorCommonPasswords.php',
'PhabricatorConduitAPIController' => 'applications/conduit/controller/PhabricatorConduitAPIController.php',
'PhabricatorConduitApplication' => 'applications/conduit/application/PhabricatorConduitApplication.php',
+ 'PhabricatorConduitCallManagementWorkflow' => 'applications/conduit/management/PhabricatorConduitCallManagementWorkflow.php',
'PhabricatorConduitCertificateToken' => 'applications/conduit/storage/PhabricatorConduitCertificateToken.php',
'PhabricatorConduitConsoleController' => 'applications/conduit/controller/PhabricatorConduitConsoleController.php',
'PhabricatorConduitContentSource' => 'infrastructure/contentsource/PhabricatorConduitContentSource.php',
@@ -2435,6 +2436,7 @@
'PhabricatorConduitLogController' => 'applications/conduit/controller/PhabricatorConduitLogController.php',
'PhabricatorConduitLogQuery' => 'applications/conduit/query/PhabricatorConduitLogQuery.php',
'PhabricatorConduitLogSearchEngine' => 'applications/conduit/query/PhabricatorConduitLogSearchEngine.php',
+ 'PhabricatorConduitManagementWorkflow' => 'applications/conduit/management/PhabricatorConduitManagementWorkflow.php',
'PhabricatorConduitMethodCallLog' => 'applications/conduit/storage/PhabricatorConduitMethodCallLog.php',
'PhabricatorConduitMethodQuery' => 'applications/conduit/query/PhabricatorConduitMethodQuery.php',
'PhabricatorConduitRequestExceptionHandler' => 'aphront/handler/PhabricatorConduitRequestExceptionHandler.php',
@@ -7822,6 +7824,7 @@
'PhabricatorCommonPasswords' => 'Phobject',
'PhabricatorConduitAPIController' => 'PhabricatorConduitController',
'PhabricatorConduitApplication' => 'PhabricatorApplication',
+ 'PhabricatorConduitCallManagementWorkflow' => 'PhabricatorConduitManagementWorkflow',
'PhabricatorConduitCertificateToken' => 'PhabricatorConduitDAO',
'PhabricatorConduitConsoleController' => 'PhabricatorConduitController',
'PhabricatorConduitContentSource' => 'PhabricatorContentSource',
@@ -7832,6 +7835,7 @@
'PhabricatorConduitLogController' => 'PhabricatorConduitController',
'PhabricatorConduitLogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorConduitLogSearchEngine' => 'PhabricatorApplicationSearchEngine',
+ 'PhabricatorConduitManagementWorkflow' => 'PhabricatorManagementWorkflow',
'PhabricatorConduitMethodCallLog' => array(
'PhabricatorConduitDAO',
'PhabricatorPolicyInterface',
diff --git a/src/applications/conduit/management/PhabricatorConduitCallManagementWorkflow.php b/src/applications/conduit/management/PhabricatorConduitCallManagementWorkflow.php
new file mode 100644
--- /dev/null
+++ b/src/applications/conduit/management/PhabricatorConduitCallManagementWorkflow.php
@@ -0,0 +1,66 @@
+<?php
+
+final class PhabricatorConduitCallManagementWorkflow
+ extends PhabricatorConduitManagementWorkflow {
+
+ protected function didConstruct() {
+ $this
+ ->setName('call')
+ ->setSynopsis(pht('Call a Conduit method..'))
+ ->setArguments(
+ array(
+ array(
+ 'name' => 'method',
+ 'param' => 'method',
+ 'help' => pht('Method to call.'),
+ ),
+ array(
+ 'name' => 'input',
+ 'param' => 'input',
+ 'help' => pht(
+ 'File to read parameters from, or "-" to read from '.
+ 'stdin.'),
+ ),
+ ));
+ }
+
+ public function execute(PhutilArgumentParser $args) {
+ $viewer = $this->getViewer();
+
+ $method = $args->getArg('method');
+ if (!strlen($method)) {
+ throw new PhutilArgumentUsageException(
+ pht('Specify a method to call with "--method".'));
+ }
+
+ $input = $args->getArg('input');
+ if (!strlen($input)) {
+ throw new PhutilArgumentUsageException(
+ pht('Specify a file to read parameters from with "--input".'));
+ }
+
+ if ($input === '-') {
+ fprintf(STDERR, tsprintf("%s\n", pht('Reading input from stdin...')));
+ $input_json = file_get_contents('php://stdin');
+ } else {
+ $input_json = Filesystem::readFile($input);
+ }
+
+ $params = phutil_json_decode($input_json);
+
+ $result = id(new ConduitCall($method, $params))
+ ->setUser($viewer)
+ ->execute();
+
+ $output = array(
+ 'result' => $result,
+ );
+
+ echo tsprintf(
+ "%B\n",
+ id(new PhutilJSON())->encodeFormatted($output));
+
+ return 0;
+ }
+
+}
diff --git a/src/applications/conduit/management/PhabricatorConduitManagementWorkflow.php b/src/applications/conduit/management/PhabricatorConduitManagementWorkflow.php
new file mode 100644
--- /dev/null
+++ b/src/applications/conduit/management/PhabricatorConduitManagementWorkflow.php
@@ -0,0 +1,4 @@
+<?php
+
+abstract class PhabricatorConduitManagementWorkflow
+ extends PhabricatorManagementWorkflow {}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 12, 7:49 AM (2 d, 3 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7578985
Default Alt Text
D18987.id45538.diff (5 KB)
Attached To
Mode
D18987: Add a `bin/conduit call` support binary
Attached
Detach File
Event Timeline
Log In to Comment