Permalink
Browse files

Make all bin/* scripts locate their workflows dynamically

Summary:
Ref T2015. Not directly related to Drydock, but I bumped into this. All these scripts currently enumerate their workflows explicitly.

Instead, use `PhutilSymbolLoader` to automatically discover workflows. This reduces code duplication and errors (see all the bad `extends` this diff fixes) and lets third parties add new workflows (not clearly valuable?).

Test Plan: Ran `bin/x help` for each modified script.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2015

Differential Revision: https://secure.phabricator.com/D7840
  • Loading branch information...
1 parent e397103 commit ce78bf1de4e5620cf0fd555331fdb4aaf9419d54 @epriestley epriestley committed Dec 27, 2013
@@ -14,9 +14,8 @@
);
$args->parseStandardArguments();
-$args->parseWorkflows(
- array(
- new DivinerGenerateWorkflow(),
- new DivinerAtomizeWorkflow(),
- new PhutilHelpArgumentWorkflow(),
- ));
+$workflows = id(new PhutilSymbolLoader())
+ ->setAncestorClass('DivinerWorkflow')
+ ->loadObjects();
+$workflows[] = new PhutilHelpArgumentWorkflow();
+$args->parseWorkflows($workflows);
@@ -14,12 +14,8 @@
);
$args->parseStandardArguments();
-$workflows = array(
- new DrydockManagementLeaseWorkflow(),
- new DrydockManagementCloseWorkflow(),
- new DrydockManagementReleaseWorkflow(),
- new DrydockManagementCreateResourceWorkflow(),
- new PhutilHelpArgumentWorkflow(),
-);
-
+$workflows = id(new PhutilSymbolLoader())
+ ->setAncestorClass('DrydockManagementWorkflow')
+ ->loadObjects();
+$workflows[] = new PhutilHelpArgumentWorkflow();
$args->parseWorkflows($workflows);
@@ -15,13 +15,8 @@
);
$args->parseStandardArguments();
-$workflows = array(
- new PhabricatorFactManagementDestroyWorkflow(),
- new PhabricatorFactManagementAnalyzeWorkflow(),
- new PhabricatorFactManagementStatusWorkflow(),
- new PhabricatorFactManagementListWorkflow(),
- new PhabricatorFactManagementCursorsWorkflow(),
- new PhutilHelpArgumentWorkflow(),
-);
-
+$workflows = id(new PhutilSymbolLoader())
+ ->setAncestorClass('PhabricatorFactManagementWorkflow')
+ ->loadObjects();
+$workflows[] = new PhutilHelpArgumentWorkflow();
$args->parseWorkflows($workflows);
@@ -14,12 +14,8 @@
);
$args->parseStandardArguments();
-$workflows = array(
- new PhabricatorFilesManagementEnginesWorkflow(),
- new PhabricatorFilesManagementMigrateWorkflow(),
- new PhabricatorFilesManagementRebuildWorkflow(),
- new PhabricatorFilesManagementPurgeWorkflow(),
- new PhutilHelpArgumentWorkflow(),
-);
-
+$workflows = id(new PhutilSymbolLoader())
+ ->setAncestorClass('PhabricatorFilesManagementWorkflow')
+ ->loadObjects();
+$workflows[] = new PhutilHelpArgumentWorkflow();
$args->parseWorkflows($workflows);
@@ -14,9 +14,8 @@
);
$args->parseStandardArguments();
-$workflows = array(
- new PhabricatorLipsumGenerateWorkflow(),
- new PhutilHelpArgumentWorkflow(),
-);
-
+$workflows = id(new PhutilSymbolLoader())
+ ->setAncestorClass('PhabricatorLipsumManagementWorkflow')
+ ->loadObjects();
+$workflows[] = new PhutilHelpArgumentWorkflow();
$args->parseWorkflows($workflows);
@@ -14,15 +14,9 @@
);
$args->parseStandardArguments();
-$workflows = array(
- new PhutilHelpArgumentWorkflow(),
- new PhabricatorMailManagementResendWorkflow(),
- new PhabricatorMailManagementShowOutboundWorkflow(),
- new PhabricatorMailManagementShowInboundWorkflow(),
- new PhabricatorMailManagementSendTestWorkflow(),
- new PhabricatorMailManagementReceiveTestWorkflow(),
- new PhabricatorMailManagementListInboundWorkflow(),
- new PhabricatorMailManagementListOutboundWorkflow(),
-);
-
+$workflows = id(new PhutilSymbolLoader())
+ ->setAncestorClass('PhabricatorMailManagementWorkflow')
+ ->loadObjects();
+$workflows[] = new PhutilHelpArgumentWorkflow();
$args->parseWorkflows($workflows);
+
@@ -15,16 +15,8 @@
);
$args->parseStandardArguments();
-$workflows = array(
- new PhabricatorRepositoryManagementPullWorkflow(),
- new PhabricatorRepositoryManagementDiscoverWorkflow(),
- new PhabricatorRepositoryManagementEditWorkflow(),
- new PhabricatorRepositoryManagementListWorkflow(),
- new PhabricatorRepositoryManagementDeleteWorkflow(),
- new PhabricatorRepositoryManagementMarkImportedWorkflow(),
- new PhabricatorRepositoryManagementLookupUsersWorkflow(),
- new PhabricatorRepositoryManagementImportingWorkflow(),
- new PhutilHelpArgumentWorkflow(),
-);
-
+$workflows = id(new PhutilSymbolLoader())
+ ->setAncestorClass('PhabricatorRepositoryManagementWorkflow')
+ ->loadObjects();
+$workflows[] = new PhutilHelpArgumentWorkflow();
$args->parseWorkflows($workflows);
@@ -14,9 +14,8 @@
);
$args->parseStandardArguments();
-$workflows = array(
- new PhabricatorSearchManagementIndexWorkflow(),
- new PhutilHelpArgumentWorkflow(),
-);
-
+$workflows = id(new PhutilSymbolLoader())
+ ->setAncestorClass('PhabricatorSearchManagementWorkflow')
+ ->loadObjects();
+$workflows[] = new PhutilHelpArgumentWorkflow();
$args->parseWorkflows($workflows);
@@ -14,9 +14,8 @@
);
$args->parseStandardArguments();
-$workflows = array(
- new PhabricatorAuditManagementDeleteWorkflow(),
- new PhutilHelpArgumentWorkflow(),
-);
-
+$workflows = id(new PhutilSymbolLoader())
+ ->setAncestorClass('PhabricatorAuditManagementWorkflow')
+ ->loadObjects();
+$workflows[] = new PhutilHelpArgumentWorkflow();
$args->parseWorkflows($workflows);
@@ -14,11 +14,8 @@
);
$args->parseStandardArguments();
-$workflows = array(
- new PhabricatorAuthManagementRecoverWorkflow(),
- new PhabricatorAuthManagementRefreshWorkflow(),
- new PhabricatorAuthManagementLDAPWorkflow(),
- new PhutilHelpArgumentWorkflow(),
-);
-
+$workflows = id(new PhutilSymbolLoader())
+ ->setAncestorClass('PhabricatorAuthManagementWorkflow')
+ ->loadObjects();
+$workflows[] = new PhutilHelpArgumentWorkflow();
$args->parseWorkflows($workflows);
@@ -14,12 +14,8 @@
);
$args->parseStandardArguments();
-$workflows = array(
- new PhabricatorConfigManagementListWorkflow(),
- new PhabricatorConfigManagementSetWorkflow(),
- new PhabricatorConfigManagementGetWorkflow(),
- new PhabricatorConfigManagementDeleteWorkflow(),
- new PhutilHelpArgumentWorkflow(),
-);
-
+$workflows = id(new PhutilSymbolLoader())
+ ->setAncestorClass('PhabricatorConfigManagementWorkflow')
+ ->loadObjects();
+$workflows[] = new PhutilHelpArgumentWorkflow();
$args->parseWorkflows($workflows);
@@ -14,9 +14,8 @@
);
$args->parseStandardArguments();
-$workflows = array(
- new PhabricatorFeedManagementRepublishWorkflow(),
- new PhutilHelpArgumentWorkflow(),
-);
-
+$workflows = id(new PhutilSymbolLoader())
+ ->setAncestorClass('PhabricatorFeedManagementWorkflow')
+ ->loadObjects();
+$workflows[] = new PhutilHelpArgumentWorkflow();
$args->parseWorkflows($workflows);
@@ -18,5 +18,4 @@
->setAncestorClass('HarbormasterManagementWorkflow')
->loadObjects();
$workflows[] = new PhutilHelpArgumentWorkflow();
-
$args->parseWorkflows($workflows);
@@ -14,10 +14,8 @@
);
$args->parseStandardArguments();
-$workflows = array(
- new PhabricatorPolicyManagementShowWorkflow(),
- new PhabricatorPolicyManagementUnlockWorkflow(),
- new PhutilHelpArgumentWorkflow(),
-);
-
+$workflows = id(new PhutilSymbolLoader())
+ ->setAncestorClass('PhabricatorPolicyManagementWorkflow')
+ ->loadObjects();
+$workflows[] = new PhutilHelpArgumentWorkflow();
$args->parseWorkflows($workflows);
@@ -99,14 +99,9 @@
exit(1);
}
-$workflows = array(
- new PhabricatorStorageManagementDatabasesWorkflow(),
- new PhabricatorStorageManagementDestroyWorkflow(),
- new PhabricatorStorageManagementDumpWorkflow(),
- new PhabricatorStorageManagementStatusWorkflow(),
- new PhabricatorStorageManagementProbeWorkflow(),
- new PhabricatorStorageManagementUpgradeWorkflow(),
-);
+$workflows = id(new PhutilSymbolLoader())
+ ->setAncestorClass('PhabricatorStorageManagementWorkflow')
+ ->loadObjects();
$patches = PhabricatorSQLPatchList::buildAllPatches();
@@ -3740,7 +3740,7 @@
'PhabricatorBuiltinPatchList' => 'PhabricatorSQLPatchList',
'PhabricatorBusyExample' => 'PhabricatorUIExample',
'PhabricatorCacheDAO' => 'PhabricatorLiskDAO',
- 'PhabricatorCacheManagementPurgeWorkflow' => 'PhabricatorSearchManagementWorkflow',
+ 'PhabricatorCacheManagementPurgeWorkflow' => 'PhabricatorCacheManagementWorkflow',
'PhabricatorCacheManagementWorkflow' => 'PhabricatorManagementWorkflow',
'PhabricatorCalendarBrowseController' => 'PhabricatorCalendarController',
'PhabricatorCalendarController' => 'PhabricatorController',
@@ -4113,13 +4113,13 @@
'PhabricatorMailImplementationPHPMailerLiteAdapter' => 'PhabricatorMailImplementationAdapter',
'PhabricatorMailImplementationSendGridAdapter' => 'PhabricatorMailImplementationAdapter',
'PhabricatorMailImplementationTestAdapter' => 'PhabricatorMailImplementationAdapter',
- 'PhabricatorMailManagementListInboundWorkflow' => 'PhabricatorSearchManagementWorkflow',
- 'PhabricatorMailManagementListOutboundWorkflow' => 'PhabricatorSearchManagementWorkflow',
- 'PhabricatorMailManagementReceiveTestWorkflow' => 'PhabricatorSearchManagementWorkflow',
- 'PhabricatorMailManagementResendWorkflow' => 'PhabricatorSearchManagementWorkflow',
- 'PhabricatorMailManagementSendTestWorkflow' => 'PhabricatorSearchManagementWorkflow',
- 'PhabricatorMailManagementShowInboundWorkflow' => 'PhabricatorSearchManagementWorkflow',
- 'PhabricatorMailManagementShowOutboundWorkflow' => 'PhabricatorSearchManagementWorkflow',
+ 'PhabricatorMailManagementListInboundWorkflow' => 'PhabricatorMailManagementWorkflow',
+ 'PhabricatorMailManagementListOutboundWorkflow' => 'PhabricatorMailManagementWorkflow',
+ 'PhabricatorMailManagementReceiveTestWorkflow' => 'PhabricatorMailManagementWorkflow',
+ 'PhabricatorMailManagementResendWorkflow' => 'PhabricatorMailManagementWorkflow',
+ 'PhabricatorMailManagementSendTestWorkflow' => 'PhabricatorMailManagementWorkflow',
+ 'PhabricatorMailManagementShowInboundWorkflow' => 'PhabricatorMailManagementWorkflow',
+ 'PhabricatorMailManagementShowOutboundWorkflow' => 'PhabricatorMailManagementWorkflow',
'PhabricatorMailManagementWorkflow' => 'PhabricatorManagementWorkflow',
'PhabricatorMailReceiverTestCase' => 'PhabricatorTestCase',
'PhabricatorMailingListPHIDTypeList' => 'PhabricatorPHIDType',
@@ -1,7 +1,7 @@
<?php
final class PhabricatorCacheManagementPurgeWorkflow
- extends PhabricatorSearchManagementWorkflow {
+ extends PhabricatorCacheManagementWorkflow {
protected function didConstruct() {
$this
@@ -1,7 +1,7 @@
<?php
final class PhabricatorMailManagementListInboundWorkflow
- extends PhabricatorSearchManagementWorkflow {
+ extends PhabricatorMailManagementWorkflow {
protected function didConstruct() {
$this
@@ -1,7 +1,7 @@
<?php
final class PhabricatorMailManagementListOutboundWorkflow
- extends PhabricatorSearchManagementWorkflow {
+ extends PhabricatorMailManagementWorkflow {
protected function didConstruct() {
$this
@@ -1,7 +1,7 @@
<?php
final class PhabricatorMailManagementReceiveTestWorkflow
- extends PhabricatorSearchManagementWorkflow {
+ extends PhabricatorMailManagementWorkflow {
protected function didConstruct() {
$this
@@ -1,7 +1,7 @@
<?php
final class PhabricatorMailManagementResendWorkflow
- extends PhabricatorSearchManagementWorkflow {
+ extends PhabricatorMailManagementWorkflow {
protected function didConstruct() {
$this
@@ -1,7 +1,7 @@
<?php
final class PhabricatorMailManagementSendTestWorkflow
- extends PhabricatorSearchManagementWorkflow {
+ extends PhabricatorMailManagementWorkflow {
protected function didConstruct() {
$this
@@ -1,7 +1,7 @@
<?php
final class PhabricatorMailManagementShowInboundWorkflow
- extends PhabricatorSearchManagementWorkflow {
+ extends PhabricatorMailManagementWorkflow {
protected function didConstruct() {
$this
@@ -1,7 +1,7 @@
<?php
final class PhabricatorMailManagementShowOutboundWorkflow
- extends PhabricatorSearchManagementWorkflow {
+ extends PhabricatorMailManagementWorkflow {
protected function didConstruct() {
$this

0 comments on commit ce78bf1

Please sign in to comment.