From 8fb864cb0b54caff7602801f4cb38f8246ce4c0c Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Mon, 20 Jan 2014 15:45:25 -0600
Subject: [PATCH] Add backend to list output; add --limit switch

Add the current backend to the list results output
Add a --limit switch to support limit results sent to a command like
`migrate`
---
 setup/cli/modules/file.php | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/setup/cli/modules/file.php b/setup/cli/modules/file.php
index 2973ff49e..3c9f434b7 100644
--- a/setup/cli/modules/file.php
+++ b/setup/cli/modules/file.php
@@ -35,6 +35,9 @@ class FileManager extends Module {
         'max-size' => array('-Z', '--max-size', 'metavar'=>'SIZE',
             'help' => 'Search for files smaller than this. k, M, G are welcome'),
 
+        'limit' => array('-L', '--limit', 'metavar'=>'count',
+            'help' => 'Limit search results to this count'),
+
         'to' => array('-m', '--to', 'metavar'=>'BK',
             'help' => 'Target backend for migration. See `backends` action
                 for a list of available backends'),
@@ -62,8 +65,8 @@ class FileManager extends Module {
             $files = FileModel::objects();
             $this->_applyCriteria($options, $files);
             foreach ($files as $f) {
-                printf("% 5d % 8d %s % 12s %s\n", $f->id, $f->size,
-                    $f->created, $f->type, $f->name);
+                printf("% 5d %s % 8d %s % 12s %s\n", $f->id, $f->bk,
+                    $f->size, $f->created, $f->type, $f->name);
             }
             break;
 
@@ -149,6 +152,12 @@ class FileManager extends Module {
                 else
                     $qs->filter(array('size__lte'=>$val));
                 break;
+
+            case 'limit':
+                if (!is_numeric($val))
+                    $this->fail('Provide an result count number to --limit');
+                $qs->limit($val);
+                break;
             }
         }
     }
-- 
GitLab