Class: Shutwork::Command::Me

Inherits:
Base
  • Object
show all
Defined in:
lib/shutwork/command/me.rb

Instance Method Summary collapse

Methods inherited from Base

#download_file, #initialize

Methods included from Display

#display_account, #display_file, #display_message, #display_room, #format_datetime, #format_filesize, #to_filesize_human

Constructor Details

This class inherits a constructor from Shutwork::Command::Base

Instance Method Details

#parse_args(args) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/shutwork/command/me.rb', line 11

def parse_args args
  opts = OptionParser.new
  opts.program_name = "shutwork #{self.class.name.split(/::/).last.downcase}"
  opts.on("-r", "--raw", "Show results in raw format") { @raw = true }
  opts.on("-v", "--verbose", "Verbose") { @verbose = true }
  opts.parse args
end

#run(args = []) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/shutwork/command/me.rb', line 19

def run args  = []
  parse_args args
  token = Shutwork::Token.read
  @client = Shutwork::Client.new token: token, verbose: @verbose

  item = @client.me
  if @raw
    puts item
  else
     JSON.parse(item)
  end
end