Class: Escalator::Command::Setup
- Inherits:
-
Escalator::Command
- Object
- CLAide::Command
- Escalator::Command
- Escalator::Command::Setup
- Defined in:
- lib/escalator/command/setup.rb
Defined Under Namespace
Classes: Help
Constant Summary
Constants inherited from Escalator::Command
DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS
Instance Attribute Summary collapse
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
-
#custom_plugins ⇒ Object
readonly
Returns the value of attribute custom_plugins.
-
#output_path ⇒ Object
readonly
Returns the value of attribute output_path.
-
#set_zshcompletion ⇒ Object
readonly
Returns the value of attribute set_zshcompletion.
Class Method Summary collapse
Instance Method Summary collapse
- #help!(error_message = nil) ⇒ Object
-
#initialize(argv) ⇒ Setup
constructor
A new instance of Setup.
- #run ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Setup
Returns a new instance of Setup.
51 52 53 54 55 56 |
# File 'lib/escalator/command/setup.rb', line 51 def initialize argv @commands = argv.arguments!.uniq @output_path = argv.option "output-path" @set_zshcompletion = argv.flag? "set-zshcompletion", false super end |
Instance Attribute Details
#commands ⇒ Object (readonly)
Returns the value of attribute commands.
18 19 20 |
# File 'lib/escalator/command/setup.rb', line 18 def commands @commands end |
#custom_plugins ⇒ Object (readonly)
Returns the value of attribute custom_plugins.
24 25 26 |
# File 'lib/escalator/command/setup.rb', line 24 def custom_plugins @custom_plugins end |
#output_path ⇒ Object (readonly)
Returns the value of attribute output_path.
20 21 22 |
# File 'lib/escalator/command/setup.rb', line 20 def output_path @output_path end |
#set_zshcompletion ⇒ Object (readonly)
Returns the value of attribute set_zshcompletion.
22 23 24 |
# File 'lib/escalator/command/setup.rb', line 22 def set_zshcompletion @set_zshcompletion end |
Class Method Details
.options ⇒ Object
44 45 46 47 48 49 |
# File 'lib/escalator/command/setup.rb', line 44 def self. [ ["--output-path=path", "path 为参数模版导出路径"], ["--set-zshcompletion", "会忽略其他参数, 只设置 oh-my-zsh 的命令补全插件到 custom/plugins 中, zshrc 配置插件, 请自己手动更新, 默认: 否"] ].concat super end |
Instance Method Details
#help!(error_message = nil) ⇒ Object
79 80 81 |
# File 'lib/escalator/command/setup.rb', line 79 def help!( = nil) invoked_command_class.help!(, Help) end |
#run ⇒ Object
83 84 85 |
# File 'lib/escalator/command/setup.rb', line 83 def run Escalator::Setup.run self end |
#validate! ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/escalator/command/setup.rb', line 58 def validate! super if set_zshcompletion if ENV["ZSH"].empty? help! "未检测到 oh-my-zsh, 请先进行安装" end @custom_plugins = "#{ENV["ZSH"]}/custom/plugins/" return end if commands.empty? help! "未检测到 COMMAND 参数" end cmds = (commands - (%w(confuse archive resign upload) & commands)) if !cmds.empty? help! "检测到 非法参数: #{cmds.join ", "}" end if !output_path help! "未检测到 --output-path 参数" end end |