Skip to content

Commit

Permalink
Make all bin/* scripts locate their workflows dynamically
Browse files Browse the repository at this point in the history
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
epriestley committed Dec 27, 2013
1 parent e397103 commit ce78bf1
Show file tree
Hide file tree
Showing 24 changed files with 73 additions and 120 deletions.
11 changes: 5 additions & 6 deletions scripts/diviner/diviner.php
Expand Up @@ -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);
12 changes: 4 additions & 8 deletions scripts/drydock/drydock_control.php
Expand Up @@ -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);
13 changes: 4 additions & 9 deletions scripts/fact/manage_facts.php
Expand Up @@ -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);
12 changes: 4 additions & 8 deletions scripts/files/manage_files.php
Expand Up @@ -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);
9 changes: 4 additions & 5 deletions scripts/lipsum/manage_lipsum.php
Expand Up @@ -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);
16 changes: 5 additions & 11 deletions scripts/mail/manage_mail.php
Expand Up @@ -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);

16 changes: 4 additions & 12 deletions scripts/repository/manage_repositories.php
Expand Up @@ -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);
9 changes: 4 additions & 5 deletions scripts/search/manage_search.php
Expand Up @@ -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);
9 changes: 4 additions & 5 deletions scripts/setup/manage_audit.php
Expand Up @@ -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);
11 changes: 4 additions & 7 deletions scripts/setup/manage_auth.php
Expand Up @@ -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);
12 changes: 4 additions & 8 deletions scripts/setup/manage_config.php
Expand Up @@ -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);
9 changes: 4 additions & 5 deletions scripts/setup/manage_feed.php
Expand Up @@ -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);
1 change: 0 additions & 1 deletion scripts/setup/manage_harbormaster.php
Expand Up @@ -18,5 +18,4 @@
->setAncestorClass('HarbormasterManagementWorkflow')
->loadObjects();
$workflows[] = new PhutilHelpArgumentWorkflow();

$args->parseWorkflows($workflows);
10 changes: 4 additions & 6 deletions scripts/setup/manage_policy.php
Expand Up @@ -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);
11 changes: 3 additions & 8 deletions scripts/sql/manage_storage.php
Expand Up @@ -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();

Expand Down
16 changes: 8 additions & 8 deletions src/__phutil_library_map__.php
Expand Up @@ -3740,7 +3740,7 @@
'PhabricatorBuiltinPatchList' => 'PhabricatorSQLPatchList',
'PhabricatorBusyExample' => 'PhabricatorUIExample',
'PhabricatorCacheDAO' => 'PhabricatorLiskDAO',
'PhabricatorCacheManagementPurgeWorkflow' => 'PhabricatorSearchManagementWorkflow',
'PhabricatorCacheManagementPurgeWorkflow' => 'PhabricatorCacheManagementWorkflow',
'PhabricatorCacheManagementWorkflow' => 'PhabricatorManagementWorkflow',
'PhabricatorCalendarBrowseController' => 'PhabricatorCalendarController',
'PhabricatorCalendarController' => 'PhabricatorController',
Expand Down Expand Up @@ -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',
Expand Down
@@ -1,7 +1,7 @@
<?php

final class PhabricatorCacheManagementPurgeWorkflow
extends PhabricatorSearchManagementWorkflow {
extends PhabricatorCacheManagementWorkflow {

protected function didConstruct() {
$this
Expand Down
@@ -1,7 +1,7 @@
<?php

final class PhabricatorMailManagementListInboundWorkflow
extends PhabricatorSearchManagementWorkflow {
extends PhabricatorMailManagementWorkflow {

protected function didConstruct() {
$this
Expand Down
@@ -1,7 +1,7 @@
<?php

final class PhabricatorMailManagementListOutboundWorkflow
extends PhabricatorSearchManagementWorkflow {
extends PhabricatorMailManagementWorkflow {

protected function didConstruct() {
$this
Expand Down
@@ -1,7 +1,7 @@
<?php

final class PhabricatorMailManagementReceiveTestWorkflow
extends PhabricatorSearchManagementWorkflow {
extends PhabricatorMailManagementWorkflow {

protected function didConstruct() {
$this
Expand Down
@@ -1,7 +1,7 @@
<?php

final class PhabricatorMailManagementResendWorkflow
extends PhabricatorSearchManagementWorkflow {
extends PhabricatorMailManagementWorkflow {

protected function didConstruct() {
$this
Expand Down
@@ -1,7 +1,7 @@
<?php

final class PhabricatorMailManagementSendTestWorkflow
extends PhabricatorSearchManagementWorkflow {
extends PhabricatorMailManagementWorkflow {

protected function didConstruct() {
$this
Expand Down
@@ -1,7 +1,7 @@
<?php

final class PhabricatorMailManagementShowInboundWorkflow
extends PhabricatorSearchManagementWorkflow {
extends PhabricatorMailManagementWorkflow {

protected function didConstruct() {
$this
Expand Down
@@ -1,7 +1,7 @@
<?php

final class PhabricatorMailManagementShowOutboundWorkflow
extends PhabricatorSearchManagementWorkflow {
extends PhabricatorMailManagementWorkflow {

protected function didConstruct() {
$this
Expand Down

0 comments on commit ce78bf1

Please sign in to comment.