~ubuntu-branches/ubuntu/wily/phabricator/wily

« back to all changes in this revision

Viewing changes to src/workflow/ArcanistStartWorkflow.php

  • Committer: Package Import Robot
  • Author(s): Richard Sellam
  • Date: 2014-11-01 23:20:06 UTC
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: package-import@ubuntu.com-20141101232006-mvlnp0cil67tsboe
Tags: upstream-0~git20141101/arcanist
Import upstream version 0~git20141101, component arcanist

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
/**
 
4
 * Start time tracking on an object
 
5
 */
 
6
final class ArcanistStartWorkflow extends ArcanistPhrequentWorkflow {
 
7
 
 
8
  public function getWorkflowName() {
 
9
    return 'start';
 
10
  }
 
11
 
 
12
  public function getCommandSynopses() {
 
13
    return phutil_console_format(<<<EOTEXT
 
14
      **start** __object__
 
15
EOTEXT
 
16
      );
 
17
  }
 
18
 
 
19
  public function getCommandHelp() {
 
20
    return phutil_console_format(<<<EOTEXT
 
21
Start tracking work in Phrequent.
 
22
EOTEXT
 
23
      );
 
24
  }
 
25
 
 
26
  public function requiresConduit() {
 
27
    return true;
 
28
  }
 
29
 
 
30
  public function desiresWorkingCopy() {
 
31
    return false;
 
32
  }
 
33
 
 
34
  public function requiresAuthentication() {
 
35
    return true;
 
36
  }
 
37
 
 
38
  public function getArguments() {
 
39
    return array(
 
40
      '*' => 'name',
 
41
    );
 
42
  }
 
43
 
 
44
  public function run() {
 
45
    $conduit = $this->getConduit();
 
46
 
 
47
    $started_phids = array();
 
48
    $short_name = $this->getArgument('name');
 
49
    foreach ($short_name as $object_name) {
 
50
      $object_lookup = $conduit->callMethodSynchronous(
 
51
        'phid.lookup',
 
52
        array(
 
53
          'names' => array($object_name),
 
54
        ));
 
55
 
 
56
      if (!array_key_exists($object_name, $object_lookup)) {
 
57
        echo "No such object '".$object_name."' found.\n";
 
58
        return 1;
 
59
      }
 
60
 
 
61
      $object_phid = $object_lookup[$object_name]['phid'];
 
62
 
 
63
      $started_phids[] = $conduit->callMethodSynchronous(
 
64
        'phrequent.push',
 
65
        array(
 
66
          'objectPHID' => $object_phid,
 
67
        ));
 
68
    }
 
69
 
 
70
    $phid_query = $conduit->callMethodSynchronous(
 
71
      'phid.query',
 
72
      array(
 
73
        'phids' => $started_phids,
 
74
      ));
 
75
 
 
76
    $name = '';
 
77
    foreach ($phid_query as $ref) {
 
78
      if ($name === '') {
 
79
        $name = $ref['fullName'];
 
80
      } else {
 
81
        $name .= ', '.$ref['fullName'];
 
82
      }
 
83
    }
 
84
 
 
85
    echo phutil_console_format(
 
86
      "Started:  %s\n\n",
 
87
      $name);
 
88
 
 
89
    $this->printCurrentTracking(true);
 
90
  }
 
91
 
 
92
}