Class: Xcodeproj::Command::Sort

Inherits:
Xcodeproj::Command show all
Defined in:
lib/xcodeproj/command/sort.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Sort

Returns a new instance of Sort.


22
23
24
25
26
27
# File 'lib/xcodeproj/command/sort.rb', line 22

def initialize(argv)
  self.xcodeproj_path = argv.shift_argument
  @group_option = argv.option('group-option')
  @group_option &&= @group_option.to_sym
  super
end

Class Method Details

.optionsObject


12
13
14
15
16
# File 'lib/xcodeproj/command/sort.rb', line 12

def self.options
  [
    ['--group-option=[above|below]', 'The position of the groups when sorting. If no option is specified, sorting will interleave groups and files.'],
  ].concat(super)
end

Instance Method Details

#runObject


37
38
39
40
41
# File 'lib/xcodeproj/command/sort.rb', line 37

def run
  xcodeproj.sort(:groups_position => @group_option)
  xcodeproj.save
  puts "The `#{File.basename(xcodeproj_path)}` project was sorted"
end

#validate!Object


29
30
31
32
33
34
35
# File 'lib/xcodeproj/command/sort.rb', line 29

def validate!
  super
  unless [nil, :above, :below].include?(@group_option)
    help! "Unknown format `#{@group_option}`"
  end
  open_project!
end