Class: Pod::Command::Setting

Inherits:
DevCommand show all
Defined in:
lib/cocoapods-devtool/command/setting.rb

Overview

TODO:

Create a PR to add your plugin to CocoaPods/cocoapods.org in the ‘plugins.json` file, once your plugin is released.

This is an example of a cocoapods plugin adding a top-level subcommand to the ‘pod’ command.

You can also create subcommands of existing or new commands. Say you wanted to add a subcommand to ‘list` to show newly deprecated pods, (e.g. `pod list deprecated`), there are a few things that would need to change.

  • move this file to ‘lib/pod/command/list/deprecated.rb` and update the class to exist in the the Pod::Command::List namespace

  • change this class to extend from ‘List` instead of `Command`. This tells the plugin system that it is a subcommand of `list`.

  • edit ‘lib/cocoapods_plugins.rb` to require this file

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Setting

Returns a new instance of Setting.



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/cocoapods-devtool/command/setting.rb', line 29

def initialize(argv)
  @key_values = argv.arguments!
  @debug_enable = argv.flag?("debug_enable",true)
  @release_enable = argv.flag?("release_enable",true)
  @distubution_enable = argv.flag?("distubution_enable",true)
  @auto_sign_enable = argv.flag?("auto_sign_enable",true)

  @settingTool = UserSetting::Setting.new()
  @setting = @settingTool.readSettingData()        
  super
end

Instance Method Details

#runObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/cocoapods-devtool/command/setting.rb', line 49

def run
  if @key_values.empty?
    UI.puts '当前的设置如下'
    UI.puts @setting
  else
  
  @key_values.each do |value|
    array = value.split("=")
    @settingTool.set(array[0],array[1])
  end
  #mode 解析
  debugMode = "Debug"
  releaseMode = "Release"
  distributionModel = "Distubution"
  modes = Array.[](debugMode,releaseMode,distributionModel)

  modes.delete(debugMode) unless @debug_enable
  modes.delete(releaseMode) unless @release_enable
  modes.delete(distributionModel) unless @distubution_enable
  @settingTool.set("modes",modes)
  #签名
  @settingTool.save()
  UI.puts "设置保存成功"
  end
end

#validate!Object



41
42
43
44
45
46
47
# File 'lib/cocoapods-devtool/command/setting.rb', line 41

def validate!
  super
  @key_values.each do |value|
    array = value.split("=")
    help! value+' 不符合key=value的格式' unless array.size == 2
  end
end