class DingTalk::Command::Markdown

Public Class Methods

new(argv) click to toggle source
Calls superclass method DingTalk::Command::new
# File lib/DingTalk/command/markdown.rb, line 26
def initialize(argv)
  @content = argv.shift_argument
  @title = argv.option('title');
  at_str = argv.option('at');
  @at_mobiles = []
  if at_str then
    at_str.split(%r{,\s*}).each do |at_mobile|
      @at_mobiles << at_mobile unless at_mobile.nil? || at_mobile.empty?
    end
  end
  @is_at_all = argv.flag?('all', false)
  super
end
options() click to toggle source
Calls superclass method DingTalk::Command::options
# File lib/DingTalk/command/markdown.rb, line 18
def self.options
  [
    %w(--title=`title` 消息内容。如果太长只会部分展示。),
    %w(--at=`at` [可选]被@人的手机号(在content里添加@人的手机号),多个手机号以英文逗号(`,`)分隔。),
    %w(--all [可选]@所有人),
  ].concat(super)
end

Public Instance Methods

run() click to toggle source
# File lib/DingTalk/command/markdown.rb, line 46
def run
  res = DingTalk::HttpHelper.send_markdown(@title, @content, @at_mobiles, @is_at_all, @token, @secret)
  puts res.bold.green
end
validate!() click to toggle source
Calls superclass method
# File lib/DingTalk/command/markdown.rb, line 40
def validate!
  super
  help! 'A message title is required.' unless @title
  help! 'A message content is required.' unless @content
end