]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Don't output "OKAY" for arc lint --output json.
authoradonohue <aran@fb.com>
Thu, 15 Dec 2011 18:02:29 +0000 (10:02 -0800)
committeradonohue <aran@fb.com>
Thu, 15 Dec 2011 19:03:17 +0000 (11:03 -0800)
Summary: --output json will be used for scripts, so support script writers a
little better.

Test Plan:
arc lint [--output {json, summary}]
arc lint --output json {--apply-patches, --never-apply-patches}

Reviewers: epriestley

Reviewed By: epriestley

CC: jack, aran, epriestley
Maniphest Tasks: T675

Differential Revision: 1220

src/lint/renderer/ArcanistLintJSONRenderer.php
src/lint/renderer/ArcanistLintRenderer.php
src/lint/renderer/ArcanistLintSummaryRenderer.php
src/workflow/lint/ArcanistLintWorkflow.php

index 580bbd81946c2e0fe9707d4a69863db92cc696ea..d5bed9a6f78c94b7c21cd06e18524644b91ceca3 100644 (file)
@@ -50,4 +50,8 @@ class ArcanistLintJSONRenderer {
 
     return json_encode($output)."\n";
   }
+
+  public function renderOkayResult() {
+    return "\n";
+  }
 }
index df2518e893fef8a6ccbcb277a16b51b24d1743c0..235e1612bba45cd8ba0bf63d085adc96bb86b6bc 100644 (file)
@@ -197,4 +197,9 @@ class ArcanistLintRenderer {
       $line,
       $data);
   }
+
+  public function renderOkayResult() {
+    return
+      phutil_console_format("<bg:green>** OKAY **</bg> No lint warnings.\n");
+  }
 }
index b580e38d8fdf92dd5a6188fea114b3c43af1277e..b5b224778209d4c699ad87db8ed5f658f6eb3c88 100644 (file)
@@ -40,4 +40,9 @@ class ArcanistLintSummaryRenderer {
 
     return implode("\n", $text);
   }
+
+  public function renderOkayResult() {
+    return
+      phutil_console_format("<bg:green>** OKAY **</bg> No lint warnings.\n");
+  }
 }
index a48313045a2f16ee0044501fc06ca95691a53004..df923d1b5c11034838cea9a72db45b2da13d00cf 100644 (file)
@@ -202,6 +202,15 @@ EOTEXT
     switch ($this->getArgument('output')) {
       case 'json':
         $renderer = new ArcanistLintJSONRenderer();
+        $prompt_patches = false;
+        $apply_patches = false;
+        if ($this->getArgument('never-apply-patches') ||
+            $this->getArgument('apply-patches')) {
+          throw new ArcanistUsageException(
+            "Automatic patch suggestion is disabled when using JSON output. ".
+            "Remove --never-apply-patches or --apply-patches."
+          );
+        }
         break;
       case 'summary':
         $renderer = new ArcanistLintSummaryRenderer();
@@ -293,8 +302,7 @@ EOTEXT
 
     if (!$this->getParentWorkflow()) {
       if ($result_code == self::RESULT_OKAY) {
-        echo phutil_console_format(
-          "<bg:green>** OKAY **</bg> No lint warnings.\n");
+        echo $renderer->renderOkayResult();
       }
     }