Repository: conan-io/conan

Issue:
[bug] Output of 'conan search <ref> --revisions --raw' failure for single result
### Environment Details (include every applicable attribute)
  * Conan version: Conan version 1.20.3
  * Python version: py 3

### Steps to reproduce (Include if Applicable)

Raw argument of `conan search --raw` is not honoured if there is a `@` in the reference.

More than one package in the cache:
```
⇒  conan search dep/0.1 --revisions --raw
dep/0.1#f732ec8d19fb3190c01f3df44f48b0e8
dep/0.1@issue/testing#f732ec8d19fb3190c01f3df44f48b0e8
```

Asking for a specific one (`--raw` is not honoured):

```
⇒  conan search dep/0.1@ --revisions --raw
Revisions for 'dep/0.1':
f732ec8d19fb3190c01f3df44f48b0e8 (No time)

⇒  conan search dep/0.1@issue/testing --revisions --raw
Revisions for 'dep/0.1@issue/testing':
f732ec8d19fb3190c01f3df44f48b0e8 (No time)
```

If there is only one in the cache (wihtout user/channel) it works:
```
⇒  conan search dep/0.1 --revisions --raw             
dep/0.1#f732ec8d19fb3190c01f3df44f48b0e8
```

If there is only one in the cache (with user/chanel) it fails:

```
⇒  conan search dep/0.1 --revisions --raw
dep/0.1@issue/testing#f732ec8d19fb3190c01f3df44f48b0e8

⇒  conan search dep/0.1@issue/testing --revisions --raw
Revisions for 'dep/0.1@issue/testing':
f732ec8d19fb3190c01f3df44f48b0e8 (No time)
```

 * Something doesn't behave the same when there is a `@` in the query.
 * And have a look to the JSON output too


Discussion:

Resolving patch:
diff --git a/conans/client/command.py b/conans/client/command.py
--- a/conans/client/command.py
+++ b/conans/client/command.py
@@ -1249,7 +1249,7 @@ def search(self, *args):
                 # Show revisions of a ref
                 if ref:
                     info = self._conan.get_recipe_revisions(repr(ref), remote_name=args.remote)
-                    self._outputer.print_revisions(ref, info, remote_name=args.remote)
+                    self._outputer.print_revisions(ref, info, args.raw, remote_name=args.remote)
                     return
 
                 # Show revisions of pref
@@ -1259,7 +1259,7 @@ def search(self, *args):
                     pass
                 else:
                     info = self._conan.get_package_revisions(repr(pref), remote_name=args.remote)
-                    self._outputer.print_revisions(ref, info, remote_name=args.remote)
+                    self._outputer.print_revisions(ref, info, args.raw, remote_name=args.remote)
                     return
 
                 # A pattern: Listing references by pattern but showing revisions
@@ -1286,7 +1286,7 @@ def search(self, *args):
                                                    outdated=args.outdated)
                 # search is done for one reference
                 self._outputer.print_search_packages(info["results"], ref, args.query,
-                                                     args.table, outdated=args.outdated)
+                                                     args.table, args.raw, outdated=args.outdated)
             else:
                 if args.table:
                     raise ConanException("'--table' argument can only be used with a reference")
diff --git a/conans/client/conan_command_output.py b/conans/client/conan_command_output.py
--- a/conans/client/conan_command_output.py
+++ b/conans/client/conan_command_output.py
@@ -234,18 +234,19 @@ def print_search_references(self, search_info, pattern, raw, all_remotes_search)
         printer = Printer(self._output)
         printer.print_search_recipes(search_info, pattern, raw, all_remotes_search)
 
-    def print_search_packages(self, search_info, reference, packages_query, table,
+    def print_search_packages(self, search_info, reference, packages_query, table, raw,
                               outdated=False):
         if table:
             html_binary_graph(search_info, reference, table)
         else:
             printer = Printer(self._output)
-            printer.print_search_packages(search_info, reference, packages_query,
+            printer.print_search_packages(search_info, reference, packages_query, raw,
                                           outdated=outdated)
 
-    def print_revisions(self, reference, revisions, remote_name=None):
+    def print_revisions(self, reference, revisions, raw, remote_name=None):
         remote_test = " at remote '%s'" % remote_name if remote_name else ""
-        self._output.info("Revisions for '%s'%s:" % (reference, remote_test))
+        if not raw:
+            self._output.info("Revisions for '%s'%s:" % (reference, remote_test))
         lines = ["%s (%s)" % (r["revision"],
                               iso8601_to_str(r["time"]) if r["time"] else "No time")
                  for r in revisions]
diff --git a/conans/client/printer.py b/conans/client/printer.py
--- a/conans/client/printer.py
+++ b/conans/client/printer.py
@@ -155,12 +155,12 @@ def print_search_recipes(self, search_info, pattern, raw, all_remotes_search):
                     ref = ConanFileReference.loads(reference)
                     self._out.writeln(ref.full_str())
 
-    def print_search_packages(self, search_info, ref, packages_query,
-                              outdated=False):
+    def print_search_packages(self, search_info, ref, packages_query, raw, outdated=False):
         assert(isinstance(ref, ConanFileReference))
-        self._out.info("Existing packages for recipe %s:\n" % str(ref))
+        if not raw:
+            self._out.info("Existing packages for recipe %s:\n" % str(ref))
         for remote_info in search_info:
-            if remote_info["remote"]:
+            if remote_info["remote"] and not raw:
                 self._out.info("Existing recipe in remote '%s':\n" % remote_info["remote"])
 
             if not remote_info["items"][0]["packages"]:
@@ -170,7 +170,8 @@ def print_search_packages(self, search_info, ref, packages_query,
                 elif remote_info["items"][0]["recipe"]:
                     warn_msg = "There are no %spackages for reference '%s', but package recipe " \
                                "found." % ("outdated " if outdated else "", str(ref))
-                self._out.info(warn_msg)
+                if not raw:
+                    self._out.info(warn_msg)
                 continue
 
             ref = remote_info["items"][0]["recipe"]["id"]


Test patch:
diff --git a/conans/test/functional/command/search_test.py b/conans/test/functional/command/search_test.py
--- a/conans/test/functional/command/search_test.py
+++ b/conans/test/functional/command/search_test.py
@@ -379,6 +379,8 @@ def search_raw_test(self):
                          "Hello/1.4.12@myuser/testing\n"
                          "Hello/1.5.10@myuser/testing\n"
                          "helloTest/1.4.10@myuser/stable\n", self.client.out)
+        self.client.run("search Hello/1.4.10@myuser/testing --raw")
+        self.assertNotIn("Existing packages for recipe", self.client.out)
 
     def search_html_table_test(self):
         self.client.run("search Hello/1.4.10@myuser/testing --table=table.html")
@@ -1344,6 +1346,10 @@ class Test(ConanFile):
         self.assertIsNotNone(j[0]["time"])
         self.assertEqual(len(j), 1)
 
+        # raw argument
+        client.run("search lib/1.0@user/testing --raw --revisions")
+        self.assertNotIn("Revisions for", client.out)
+
     def search_package_revisions_test(self):
         test_server = TestServer(users={"user": "password"})  # exported users and passwords
         servers = {"default": test_server}