notes-cli 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/notes +2 -0
- data/lib/notes-cli.rb +22 -8
- data/lib/notes-cli/version.rb +1 -1
- metadata +1 -1
data/bin/notes
CHANGED
data/lib/notes-cli.rb
CHANGED
@@ -77,20 +77,34 @@ class Notes
|
|
77
77
|
counter = 1
|
78
78
|
tasks = []
|
79
79
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
80
|
+
begin
|
81
|
+
File.read(filename).each_line do |line|
|
82
|
+
if @options[:flags].any? { |flag| line =~ /#{flag}/i }
|
83
|
+
tasks << {
|
84
|
+
:line_num => counter,
|
85
|
+
:line => line.strip
|
86
|
+
}
|
87
|
+
end
|
88
|
+
counter += 1
|
86
89
|
end
|
87
|
-
|
90
|
+
rescue
|
91
|
+
# Error occurred reading the file (ex. invalid byte sequence in UTF-8)
|
92
|
+
# Move on quietly
|
88
93
|
end
|
89
94
|
|
90
95
|
if !tasks.empty?
|
91
96
|
name.slice!(0) if name.start_with?("/")
|
92
97
|
puts "#{name}:"
|
93
|
-
|
98
|
+
|
99
|
+
tasks.each do |task|
|
100
|
+
flag_regex = Regexp.new(@options[:flags].join('|'), true)
|
101
|
+
color = 33 # yellow
|
102
|
+
line = task[:line].gsub(flag_regex) do |flag|
|
103
|
+
"\e[#{color};1m#{flag}\033[0m"
|
104
|
+
end
|
105
|
+
puts " ln #{task[:line_num]}: #{line}"
|
106
|
+
end
|
107
|
+
|
94
108
|
puts ""
|
95
109
|
end
|
96
110
|
end
|
data/lib/notes-cli/version.rb
CHANGED