Method: NA.list_todos

Defined in:
lib/na/next_action.rb

.list_todos(query: []) ⇒ Object



813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
# File 'lib/na/next_action.rb', line 813

def list_todos(query: [])
  dirs = if query
           match_working_dir(query, distance: 2, require_last: false)
         else
           file = database_path
           content = File.exist?(file) ? file.read_file.strip : ''
           notify("#{NA.theme[:error]}Database empty", exit_code: 1) if content.empty?

           content.split(/\n/)
         end

  dirs.map! do |dir|
    dir.highlight_filename
  end

  puts NA::Color.template(dirs.join("\n"))
end