本文簡要介紹ruby語言中 Gem::CommandManager類
的用法。
命令管理器注冊並安裝 gem 命令支持的所有單獨的sub-commands。
可以通過在已安裝的 gem 中編寫 rubygems_plugin.rb 文件來提供額外的命令。您應該針對 Gem::CommandManager
實例注冊您的命令,如下所示:
# file rubygems_plugin.rb
require 'rubygems/command_manager'
Gem::CommandManager.instance.register_command :edit
你應該把你的命令的實現放在 rubygems/commands 中。
# file rubygems/commands/edit_command.rb
class Gem::Commands::EditCommand < Gem::Command
# ...
end
有關編寫 gem 命令的說明,請參閱 Gem::Command
。
相關用法
- Ruby Command.arguments用法及代碼示例
- Ruby Command.defaults_str用法及代碼示例
- Ruby Command.deprecate_option用法及代碼示例
- Ruby Comment.extract_call_seq用法及代碼示例
- Ruby Comment.remove_private用法及代碼示例
- Ruby Comparable.between?用法及代碼示例
- Ruby Complex.arg用法及代碼示例
- Ruby ComposedSet類用法及代碼示例
- Ruby Complex.abs2用法及代碼示例
- Ruby Complex.angle用法及代碼示例
- Ruby Complex.polar用法及代碼示例
- Ruby Comparable.clamp用法及代碼示例
- Ruby Complex.to_f用法及代碼示例
- Ruby Complex.cmp / numeric用法及代碼示例
- Ruby Complex.conj用法及代碼示例
- Ruby Complex類用法及代碼示例
- Ruby Complex.infinite?用法及代碼示例
- Ruby Complex.abs用法及代碼示例
- Ruby Complex conjugate()用法及代碼示例
- Ruby Complex.phase用法及代碼示例
- Ruby Complex.rationalize用法及代碼示例
- Ruby Complex.cmp ==用法及代碼示例
- Ruby Complex.imaginary用法及代碼示例
- Ruby Complex.cmp * numeric用法及代碼示例
- Ruby Complex.fdiv用法及代碼示例
注:本文由純淨天空篩選整理自ruby-lang.org大神的英文原創作品 CommandManager類。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。