Class: TDCLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/tdcli.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ TDCLI

Returns a new instance of TDCLI.



7
8
9
10
11
# File 'lib/tdcli.rb', line 7

def initialize(*args)
    super
    @todoistClient = TdCLI::Client.new
    @cache = TdCLI::Cache.new
end

Instance Method Details

#projectsObject



39
40
41
42
43
44
# File 'lib/tdcli.rb', line 39

def projects
    projects = @cache.get('Projects').sort_by {|hsh| hsh['item_order']}
    projects.each do |project|
        puts ' ' *(project['indent']-1) + "#{project['name']}"
    end
end

#tasksObject



14
15
16
17
18
19
20
# File 'lib/tdcli.rb', line 14

def tasks
    items = @cache.get('Items')
    items.each do |item|
        puts "- #{item['content']}"
    end

end

#updateObject



31
32
33
34
35
36
# File 'lib/tdcli.rb', line 31

def update
    resource_types = ["all"]
    data = @todoistClient.sync(resource_types)
    @cache.set(data)
    @cache.save()
end

#userObject



23
24
25
26
27
28
# File 'lib/tdcli.rb', line 23

def user
    user = @cache.get('User')
    user.each do |key, value|
        puts "#{key}: #{value}"
    end
end