3 final class NuanceManagementImportWorkflow
4 extends NuanceManagementWorkflow
{
6 protected function didConstruct() {
9 ->setExamples('**import** --source __source__ [__options__]')
10 ->setSynopsis(pht('Import data from a source.'))
16 'help' => pht('Choose which source to import.'),
21 'help' => pht('Import only a particular cursor.'),
26 public function execute(PhutilArgumentParser
$args) {
27 $source = $this->loadSource($args, 'source');
29 $definition = $source->getDefinition()
30 ->setViewer($this->getViewer())
33 if (!$definition->hasImportCursors()) {
34 throw new PhutilArgumentUsageException(
36 'This source ("%s") does not expose import cursors.',
40 $cursors = $definition->getImportCursors();
42 throw new PhutilArgumentUsageException(
44 'This source ("%s") does not have any import cursors.',
48 $select = $args->getArg('cursor');
49 if (strlen($select)) {
50 if (empty($cursors[$select])) {
51 throw new PhutilArgumentUsageException(
53 'This source ("%s") does not have a "%s" cursor. Available '.
57 implode(', ', array_keys($cursors))));
62 'Importing cursor "%s" only.',
64 $cursors = array_select_keys($cursors, array($select));
70 'Importing all cursors: %s.',
71 implode(', ', array_keys($cursors))));
75 pht('(Use --cursor to import only a particular cursor.)'));
78 foreach ($cursors as $cursor) {
79 $cursor->importFromSource();