@@ -57,7 +57,10 @@ class Console::CommandDispatcher::Stdapi::Fs
57
57
# Options for the ls command
58
58
#
59
59
@@lls_opts = Rex ::Parser ::Arguments . new (
60
- "-h" => [ false , "Help banner." ] )
60
+ "-h" => [ false , "Help banner." ] ,
61
+ "-t" => [ false , "Sort by time" ] ,
62
+ "-s" => [ false , "Sort by size" ] ,
63
+ "-r" => [ false , "Reverse sort order" ] )
61
64
62
65
#
63
66
# List of supported commands.
@@ -686,12 +689,12 @@ def cmd_lls_help
686
689
#
687
690
# Get list local path information for lls command
688
691
#
689
- def list_local_path ( path )
692
+ def list_local_path ( path , sort , order )
690
693
columns = [ 'Mode' , 'Size' , 'Type' , 'Last modified' , 'Name' ]
691
694
tbl = Rex ::Text ::Table . new (
692
695
'Header' => "Listing Local: #{ path } " ,
693
- 'SortIndex' => columns . index ( "Name" ) ,
694
- 'SortOrder' => :forward ,
696
+ 'SortIndex' => columns . index ( sort ) ,
697
+ 'SortOrder' => order ,
695
698
'Columns' => columns )
696
699
697
700
items = 0
@@ -740,10 +743,20 @@ def list_local_path(path)
740
743
#
741
744
def cmd_lls ( *args )
742
745
path = ::Dir . pwd
746
+ sort = 'Name'
747
+ order = :forward
743
748
744
749
# Parse the args
745
750
@@lls_opts . parse ( args ) { |opt , idx , val |
746
751
case opt
752
+ # Sort options
753
+ when '-s'
754
+ sort = 'Size'
755
+ when '-t'
756
+ sort = 'Last modified'
757
+ # Output options
758
+ when '-r'
759
+ order = :reverse
747
760
# Help and path
748
761
when "-h"
749
762
cmd_lls_help
@@ -753,7 +766,7 @@ def cmd_lls(*args)
753
766
end
754
767
}
755
768
756
- list_local_path ( path )
769
+ list_local_path ( path , sort , order )
757
770
end
758
771
759
772
#
0 commit comments