Skip to content

Commit ce78bf1

Browse files
author
epriestley
committed
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
1 parent e397103 commit ce78bf1

24 files changed

+73
-120
lines changed

scripts/diviner/diviner.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
);
1515
$args->parseStandardArguments();
1616

17-
$args->parseWorkflows(
18-
array(
19-
new DivinerGenerateWorkflow(),
20-
new DivinerAtomizeWorkflow(),
21-
new PhutilHelpArgumentWorkflow(),
22-
));
17+
$workflows = id(new PhutilSymbolLoader())
18+
->setAncestorClass('DivinerWorkflow')
19+
->loadObjects();
20+
$workflows[] = new PhutilHelpArgumentWorkflow();
21+
$args->parseWorkflows($workflows);

scripts/drydock/drydock_control.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@
1414
);
1515
$args->parseStandardArguments();
1616

17-
$workflows = array(
18-
new DrydockManagementLeaseWorkflow(),
19-
new DrydockManagementCloseWorkflow(),
20-
new DrydockManagementReleaseWorkflow(),
21-
new DrydockManagementCreateResourceWorkflow(),
22-
new PhutilHelpArgumentWorkflow(),
23-
);
24-
17+
$workflows = id(new PhutilSymbolLoader())
18+
->setAncestorClass('DrydockManagementWorkflow')
19+
->loadObjects();
20+
$workflows[] = new PhutilHelpArgumentWorkflow();
2521
$args->parseWorkflows($workflows);

scripts/fact/manage_facts.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,8 @@
1515
);
1616
$args->parseStandardArguments();
1717

18-
$workflows = array(
19-
new PhabricatorFactManagementDestroyWorkflow(),
20-
new PhabricatorFactManagementAnalyzeWorkflow(),
21-
new PhabricatorFactManagementStatusWorkflow(),
22-
new PhabricatorFactManagementListWorkflow(),
23-
new PhabricatorFactManagementCursorsWorkflow(),
24-
new PhutilHelpArgumentWorkflow(),
25-
);
26-
18+
$workflows = id(new PhutilSymbolLoader())
19+
->setAncestorClass('PhabricatorFactManagementWorkflow')
20+
->loadObjects();
21+
$workflows[] = new PhutilHelpArgumentWorkflow();
2722
$args->parseWorkflows($workflows);

scripts/files/manage_files.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@
1414
);
1515
$args->parseStandardArguments();
1616

17-
$workflows = array(
18-
new PhabricatorFilesManagementEnginesWorkflow(),
19-
new PhabricatorFilesManagementMigrateWorkflow(),
20-
new PhabricatorFilesManagementRebuildWorkflow(),
21-
new PhabricatorFilesManagementPurgeWorkflow(),
22-
new PhutilHelpArgumentWorkflow(),
23-
);
24-
17+
$workflows = id(new PhutilSymbolLoader())
18+
->setAncestorClass('PhabricatorFilesManagementWorkflow')
19+
->loadObjects();
20+
$workflows[] = new PhutilHelpArgumentWorkflow();
2521
$args->parseWorkflows($workflows);

scripts/lipsum/manage_lipsum.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
);
1515
$args->parseStandardArguments();
1616

17-
$workflows = array(
18-
new PhabricatorLipsumGenerateWorkflow(),
19-
new PhutilHelpArgumentWorkflow(),
20-
);
21-
17+
$workflows = id(new PhutilSymbolLoader())
18+
->setAncestorClass('PhabricatorLipsumManagementWorkflow')
19+
->loadObjects();
20+
$workflows[] = new PhutilHelpArgumentWorkflow();
2221
$args->parseWorkflows($workflows);

scripts/mail/manage_mail.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,9 @@
1414
);
1515
$args->parseStandardArguments();
1616

17-
$workflows = array(
18-
new PhutilHelpArgumentWorkflow(),
19-
new PhabricatorMailManagementResendWorkflow(),
20-
new PhabricatorMailManagementShowOutboundWorkflow(),
21-
new PhabricatorMailManagementShowInboundWorkflow(),
22-
new PhabricatorMailManagementSendTestWorkflow(),
23-
new PhabricatorMailManagementReceiveTestWorkflow(),
24-
new PhabricatorMailManagementListInboundWorkflow(),
25-
new PhabricatorMailManagementListOutboundWorkflow(),
26-
);
27-
17+
$workflows = id(new PhutilSymbolLoader())
18+
->setAncestorClass('PhabricatorMailManagementWorkflow')
19+
->loadObjects();
20+
$workflows[] = new PhutilHelpArgumentWorkflow();
2821
$args->parseWorkflows($workflows);
22+

scripts/repository/manage_repositories.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,8 @@
1515
);
1616
$args->parseStandardArguments();
1717

18-
$workflows = array(
19-
new PhabricatorRepositoryManagementPullWorkflow(),
20-
new PhabricatorRepositoryManagementDiscoverWorkflow(),
21-
new PhabricatorRepositoryManagementEditWorkflow(),
22-
new PhabricatorRepositoryManagementListWorkflow(),
23-
new PhabricatorRepositoryManagementDeleteWorkflow(),
24-
new PhabricatorRepositoryManagementMarkImportedWorkflow(),
25-
new PhabricatorRepositoryManagementLookupUsersWorkflow(),
26-
new PhabricatorRepositoryManagementImportingWorkflow(),
27-
new PhutilHelpArgumentWorkflow(),
28-
);
29-
18+
$workflows = id(new PhutilSymbolLoader())
19+
->setAncestorClass('PhabricatorRepositoryManagementWorkflow')
20+
->loadObjects();
21+
$workflows[] = new PhutilHelpArgumentWorkflow();
3022
$args->parseWorkflows($workflows);

scripts/search/manage_search.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
);
1515
$args->parseStandardArguments();
1616

17-
$workflows = array(
18-
new PhabricatorSearchManagementIndexWorkflow(),
19-
new PhutilHelpArgumentWorkflow(),
20-
);
21-
17+
$workflows = id(new PhutilSymbolLoader())
18+
->setAncestorClass('PhabricatorSearchManagementWorkflow')
19+
->loadObjects();
20+
$workflows[] = new PhutilHelpArgumentWorkflow();
2221
$args->parseWorkflows($workflows);

scripts/setup/manage_audit.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
);
1515
$args->parseStandardArguments();
1616

17-
$workflows = array(
18-
new PhabricatorAuditManagementDeleteWorkflow(),
19-
new PhutilHelpArgumentWorkflow(),
20-
);
21-
17+
$workflows = id(new PhutilSymbolLoader())
18+
->setAncestorClass('PhabricatorAuditManagementWorkflow')
19+
->loadObjects();
20+
$workflows[] = new PhutilHelpArgumentWorkflow();
2221
$args->parseWorkflows($workflows);

scripts/setup/manage_auth.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@
1414
);
1515
$args->parseStandardArguments();
1616

17-
$workflows = array(
18-
new PhabricatorAuthManagementRecoverWorkflow(),
19-
new PhabricatorAuthManagementRefreshWorkflow(),
20-
new PhabricatorAuthManagementLDAPWorkflow(),
21-
new PhutilHelpArgumentWorkflow(),
22-
);
23-
17+
$workflows = id(new PhutilSymbolLoader())
18+
->setAncestorClass('PhabricatorAuthManagementWorkflow')
19+
->loadObjects();
20+
$workflows[] = new PhutilHelpArgumentWorkflow();
2421
$args->parseWorkflows($workflows);

0 commit comments

Comments
 (0)