Class: Pindo::Command::Utils::Icon
- Inherits:
-
Pindo::Command::Utils
- Object
- CLAide::Command
- Pindo::Command
- Pindo::Command::Utils
- Pindo::Command::Utils::Icon
- Extended by:
- Executable
- Defined in:
- lib/pindo/command/utils/icon.rb
Constant Summary
Constants inherited from Pindo::Command
DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS
Instance Attribute Summary
Attributes inherited from Pindo::Command
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Icon
constructor
A new instance of Icon.
- #run ⇒ Object
- #validate! ⇒ Object
Methods included from Executable
capture_command, executable, execute_command, which, which!
Methods inherited from Pindo::Command
Methods included from Funlog::Mixin
Methods included from Pindoconfig::Mixin
Methods included from Githelper
#add_branch, #add_tag, #add_tag_with_check, #clone_clang_repo, #clone_devclang_repo, #clone_pindo_common_config_repo, #clone_pindo_env_config_repo, #clong_buildconfig_repo, #get_repo_base_name, #getcode_to_dir, #git_addpush_repo, #git_latest_commit_id, #local_branch_exists?, #local_tag_exists?, #prepare_gitenv, #process_need_add_files, #remote_branch_exists?, #remote_tag_exists?, #remove_branch, #remove_tag
Constructor Details
#initialize(argv) ⇒ Icon
Returns a new instance of Icon.
35 36 37 38 39 40 |
# File 'lib/pindo/command/utils/icon.rb', line 35 def initialize(argv) @icon_name = argv.shift_argument @args_install_flag = argv.flag?('install', false) super(argv) @additional_args = argv.remainder! end |
Class Method Details
.options ⇒ Object
29 30 31 32 33 |
# File 'lib/pindo/command/utils/icon.rb', line 29 def self. [ ['--install', '生成icon后拷贝进Xcode工程里, 用法 pindo utils icon --install'], ].concat(super) end |
Instance Method Details
#run ⇒ Object
47 48 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 74 75 |
# File 'lib/pindo/command/utils/icon.rb', line 47 def run icon_name = @icon_name time = Time.now.strftime('%m%d-%H%M%S') new_icon_dir = File.join(Dir.pwd, "icon_"+time) Funlog.instance.("正在生成icon...") begin XcodeResHelper.create_icons(icon_name: icon_name, new_icon_dir: new_icon_dir) Funlog.instance.("生成icon成功!") rescue StandardError => e Funlog.instance.("生成icon失败!") end if @args_install_flag Funlog.instance.("正在给Xcode替换icon...") XcodeResHelper.install_icon(proj_dir: Dir.pwd, new_icon_dir: new_icon_dir) Funlog.instance.("Xcode替换icon完成!") begin FileUtils.remove_dir(new_icon_dir) rescue StandardError => e end else puts "open #{new_icon_dir}" end end |
#validate! ⇒ Object
42 43 44 45 |
# File 'lib/pindo/command/utils/icon.rb', line 42 def validate! super help! 'Need a icon name' if @icon_name.nil? || @icon_name.empty? end |