Class: TasksCommand

Inherits:
NeverdoneCommand show all
Defined in:
bin/nd

Instance Method Summary collapse

Methods inherited from NeverdoneCommand

#authenticate, #execute

Instance Method Details

#lazy_executeObject



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'bin/nd', line 83

def lazy_execute
  count = 0
  notes = []
  if all?
    notes = @notebook.find_notes
  else
    notes = @notebook.find_notes("-intitle:s:done")
  end
  notes.sort! { |a,b| if a.title =~ /s:done/; -1; else 1;end}
  notes.each do |n|
    title = n.title
    count += 1
    flags = []
    if title =~ /(s:done)/
      flags << "s:done".green.bold

      title.gsub!($1, '')
    end
    if title =~ /(l:\w+)/
      flags << $1.white.bold
      title.gsub!(/(l:\w+)/, '')
    end

    if flags.size > 0
      puts "#{count}. #{title.ljust(40)} [#{flags.join(',')}]"
    else
      puts "#{count}. #{title}"
    end
  end
end