watson-ruby 1.0.6 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +12 -2
- data/lib/watson/command.rb +77 -35
- data/lib/watson/config.rb +5 -0
- data/lib/watson/printer.rb +24 -19
- data/lib/watson/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec33e9094845f5023da89a937a235da967c88d82
|
4
|
+
data.tar.gz: afd3ea9e2c2a491f7c3e81dd01634502563f3a4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be68174eb42d076b5ed0c063cc972e9b5bf5574be6c22673ee6a432e6df1e2c88dd811965fe44e4f15bd0c9150c88372b0392cd9e838ab88225f0ea413c1bcdc
|
7
|
+
data.tar.gz: 94ffaf78d6a230ce4402944bbaab9a73ea562b61eae2cc2eb6bafef9051489569ae0e530bddf56e1b45244485ddbab648e1e38b7c9f0a223f62f322802993b02
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -56,15 +56,16 @@ Usage: watson [OPTION]...
|
|
56
56
|
Running watson with no arguments will parse with settings in RC file
|
57
57
|
If no RC file exists, default RC file will be created
|
58
58
|
|
59
|
-
-c, --context-lines
|
59
|
+
-c, --context-lines number of lines of context to provide with posted issue
|
60
60
|
-d, --dirs list of directories to search in
|
61
61
|
-f, --files list of files to search in
|
62
62
|
-h, --help print help
|
63
63
|
-i, --ignore list of files, directories, or types to ignore
|
64
64
|
-p, --parse-depth depth to recursively parse directories
|
65
65
|
-r, --remote list / create tokens for Bitbucket/Github
|
66
|
+
-s, --show whether to show [all, clean, dirty] files
|
66
67
|
-t, --tags list of tags to search for
|
67
|
-
-u, --update
|
68
|
+
-u, --update update remote repos with current issues
|
68
69
|
-v, --version print watson version and info
|
69
70
|
|
70
71
|
Any number of files, tags, dirs, and ignores can be listed after flag
|
@@ -83,6 +84,7 @@ This parameter specifies how many lines of context watson should include when po
|
|
83
84
|
When this parameter is set from the command line, the .watsonrc config file is written with the value; the command line option effectively sets the default value for this feature in the current directory.
|
84
85
|
The default value is set to 15 (and can be found in the lib/watson/command.rb file).
|
85
86
|
|
87
|
+
|
86
88
|
### -d, --dirs [DIRS]
|
87
89
|
This parameter specifies which directories watson should parse through.
|
88
90
|
It should be followed by a space separated list of directories that should be parsed.
|
@@ -117,6 +119,14 @@ If passed without any options, the currently established remotes will be listed.
|
|
117
119
|
If passed with a github or bitbucket argument, watson will proceed to ask some questions to set up the corresponding remote.
|
118
120
|
|
119
121
|
|
122
|
+
### -s, --show [ALL, CLEAN, DIRTY]
|
123
|
+
This parameter is used to specify which types of files and entries are shown when watson is run.
|
124
|
+
If passed with the `clean` argument, only files that watson did *NOT* find issues in will be displayed.
|
125
|
+
If passed with the `dirty` argument, only files that watson *DID* find issues in will be displayed.
|
126
|
+
If passed with the `all` argument, watson will display all files, regardless of their issue status.
|
127
|
+
The default behavior of watson is the `all` option.
|
128
|
+
|
129
|
+
|
120
130
|
### -t, --tags [TAGS]
|
121
131
|
This parameter is used to specify which tags watson should look for when parsing.
|
122
132
|
The tag currently supports any regular character and number combination, no special (!@#$...) characters.
|
data/lib/watson/command.rb
CHANGED
@@ -24,16 +24,17 @@ module Watson
|
|
24
24
|
|
25
25
|
# List of possible flags, used later in parsing and for user reference
|
26
26
|
_flag_list = ["-c", "--context-depth",
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
27
|
+
"-d", "--dirs",
|
28
|
+
"-f", "--files",
|
29
|
+
"-h", "--help",
|
30
|
+
"-i", "--ignore",
|
31
|
+
"-p", "--parse-depth",
|
32
|
+
"-r", "--remote",
|
33
|
+
"-s", "--show",
|
34
|
+
"-t", "--tags",
|
35
|
+
"-u", "--update",
|
36
|
+
"-v", "--version"
|
37
|
+
]
|
37
38
|
|
38
39
|
|
39
40
|
# If we get the version or help flag, ignore all other flags
|
@@ -132,6 +133,10 @@ module Watson
|
|
132
133
|
# If setting up remote, exit afterwards
|
133
134
|
exit true
|
134
135
|
|
136
|
+
when "-s", "--show"
|
137
|
+
debug_print "Found -s/--show argument\n"
|
138
|
+
set_show_type(_flag_args)
|
139
|
+
|
135
140
|
when "-t", "--tags"
|
136
141
|
debug_print "Found -t/--tags argument\n"
|
137
142
|
set_tags(_flag_args)
|
@@ -163,33 +168,34 @@ module Watson
|
|
163
168
|
|
164
169
|
print BOLD;
|
165
170
|
print "Usage: watson [OPTION]...\n"
|
166
|
-
|
167
|
-
|
171
|
+
print "Running watson with no arguments will parse with settings in RC file\n"
|
172
|
+
print "If no RC file exists, default RC file will be created\n"
|
168
173
|
|
169
|
-
|
174
|
+
print "\n"
|
170
175
|
print " -c, --context-depth number of lines of context to provide with posted issue\n"
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
176
|
+
print " -d, --dirs list of directories to search in\n"
|
177
|
+
print " -f, --files list of files to search in\n"
|
178
|
+
print " -h, --help print help\n"
|
179
|
+
print " -i, --ignore list of files, directories, or types to ignore\n"
|
180
|
+
print " -p, --parse-depth depth to recursively parse directories\n"
|
181
|
+
print " -r, --remote list / create tokens for Bitbucket/GitHub\n"
|
182
|
+
print " -s, --show whether to show [all, clean, dirty] files\n"
|
183
|
+
print " -t, --tags list of tags to search for\n"
|
184
|
+
print " -u, --update update remote repos with current issues\n"
|
185
|
+
print " -v, --version print watson version and info\n"
|
186
|
+
print "\n"
|
187
|
+
|
188
|
+
print "Any number of files, tags, dirs, and ignores can be listed after flag\n"
|
189
|
+
print "Ignored files should be space separated\n"
|
190
|
+
print "To use *.filetype identifier, encapsulate in \"\" to avoid shell substitutions \n"
|
191
|
+
print "\n"
|
192
|
+
|
193
|
+
print "Report bugs to: watson\@goosecode.com\n"
|
194
|
+
print "watson home page: <http://goosecode.com/projects/watson>\n"
|
195
|
+
print "[goosecode] labs | 2012-2013\n"
|
196
|
+
print RESET;
|
197
|
+
|
198
|
+
return true
|
193
199
|
|
194
200
|
end
|
195
201
|
|
@@ -465,6 +471,42 @@ module Watson
|
|
465
471
|
end
|
466
472
|
end
|
467
473
|
|
474
|
+
|
475
|
+
###########################################################
|
476
|
+
# set_show
|
477
|
+
# Set what files watson should show
|
478
|
+
def set_show_type(args)
|
479
|
+
|
480
|
+
# Identify method entry
|
481
|
+
debug_print "#{ self } : #{ __method__ }\n"
|
482
|
+
|
483
|
+
# This should be a single value, either all, clean, or dirty
|
484
|
+
# If they pass more, just take the last valid value
|
485
|
+
if args.length <= 0
|
486
|
+
debug_print "No args passed, exiting\n"
|
487
|
+
return false
|
488
|
+
end
|
489
|
+
|
490
|
+
args.each do | _show |
|
491
|
+
case _show.downcase
|
492
|
+
when 'clean'
|
493
|
+
debug_print "Setting config show to #{ _show }\n"
|
494
|
+
@config.show_type = 'clean'
|
495
|
+
|
496
|
+
when 'dirty'
|
497
|
+
debug_print "Setting config show to #{ _show }\n"
|
498
|
+
@config.show_type = 'dirty'
|
499
|
+
|
500
|
+
else
|
501
|
+
debug_print "Setting config show to #{ _show }\n"
|
502
|
+
@config.show_type = 'all'
|
503
|
+
end
|
504
|
+
|
505
|
+
end
|
506
|
+
|
507
|
+
debug_print "Updated show to: #{ @config.show_type }\n"
|
508
|
+
return true
|
509
|
+
end
|
468
510
|
end
|
469
511
|
end
|
470
512
|
end
|
data/lib/watson/config.rb
CHANGED
@@ -33,6 +33,9 @@ module Watson
|
|
33
33
|
# Flag for command line setting of tag to parse for
|
34
34
|
attr_accessor :cl_tag_set
|
35
35
|
|
36
|
+
# Entries that watson should show
|
37
|
+
attr_accessor :show_type
|
38
|
+
|
36
39
|
# Flag for whether less is avaliable to print results
|
37
40
|
attr_reader :use_less
|
38
41
|
# Flag for where the temp file for printing is located
|
@@ -86,6 +89,8 @@ module Watson
|
|
86
89
|
@cl_tag_set = false
|
87
90
|
@cl_ignore_set = false
|
88
91
|
|
92
|
+
@show_type = 'all'
|
93
|
+
|
89
94
|
# System flags
|
90
95
|
# [todo] - Add option to save output to file also
|
91
96
|
@use_less = false
|
data/lib/watson/printer.rb
CHANGED
@@ -5,17 +5,17 @@ module Watson
|
|
5
5
|
# in the printer.rb file at least
|
6
6
|
|
7
7
|
BOLD = "\e[01m"
|
8
|
-
UNDERLINE
|
8
|
+
UNDERLINE = "\e[4m"
|
9
9
|
RESET = "\e[00m"
|
10
10
|
|
11
|
-
GRAY
|
12
|
-
RED
|
13
|
-
GREEN
|
14
|
-
YELLOW
|
15
|
-
BLUE
|
16
|
-
MAGENTA
|
17
|
-
CYAN
|
18
|
-
WHITE
|
11
|
+
GRAY = "\e[38;5;0m"
|
12
|
+
RED = "\e[38;5;1m"
|
13
|
+
GREEN = "\e[38;5;2m"
|
14
|
+
YELLOW = "\e[38;5;3m"
|
15
|
+
BLUE = "\e[38;5;4m"
|
16
|
+
MAGENTA = "\e[38;5;5m"
|
17
|
+
CYAN = "\e[38;5;6m"
|
18
|
+
WHITE = "\e[38;5;7m"
|
19
19
|
|
20
20
|
|
21
21
|
# Printer class that handles all formatting and printing of parsed dir/file structure
|
@@ -224,16 +224,22 @@ module Watson
|
|
224
224
|
|
225
225
|
# If no issues for this file, print that and break
|
226
226
|
# The filename print is repetative, but reduces another check later
|
227
|
-
if entry[:has_issues]
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
227
|
+
if !entry[:has_issues]
|
228
|
+
if @config.show_type != 'dirty'
|
229
|
+
debug_print "No issues for #{ entry }\n"
|
230
|
+
print_status "o", GREEN
|
231
|
+
cprint BOLD + UNDERLINE + GREEN + "#{ entry[:relative_path] }" + RESET + "\n"
|
232
|
+
return true
|
233
|
+
end
|
232
234
|
else
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
235
|
+
if @config.show_type != 'clean'
|
236
|
+
debug_print "Issues found for #{ entry }\n"
|
237
|
+
cprint "\n"
|
238
|
+
print_status "x", RED
|
239
|
+
cprint BOLD + UNDERLINE + RED + "#{entry[:relative_path]}" + RESET + "\n"
|
240
|
+
else
|
241
|
+
return true
|
242
|
+
end
|
237
243
|
end
|
238
244
|
|
239
245
|
|
@@ -246,7 +252,6 @@ module Watson
|
|
246
252
|
# Maybe have individual has_issues for each one?
|
247
253
|
if entry[_tag].size.zero?
|
248
254
|
debug_print "#{ _tag } has no issues, skipping\n"
|
249
|
-
cprint "\n"
|
250
255
|
next
|
251
256
|
end
|
252
257
|
|
data/lib/watson/version.rb
CHANGED