cql_ruby 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/cql_ruby +88 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ff996bf0e61aa22dd53f9eaf9768f1d2748ccf56a35bf4fb4cc2d65ed1d1e08
|
4
|
+
data.tar.gz: fbe683ebe25ab5f2a93a42c1f182ec665852536bf3deca9315ba6bf8084e9b24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1f7f6577eb7117f8f58057f880dd3dad25caf528a32251114aae9fb922583dcd2b6407b4ab782a4419dd040b04c47b5869fb4e49d0e5923c4ce55ae97c7f6ab
|
7
|
+
data.tar.gz: 58aca7b1d4323135126fd78c2b6b21df2cdd3b6ae6bdc06f211e75589349c2d286460bcf46f41211024e6bb0d07f4fe68b8364ad1a562ac9a697bdb3cf1ea16b
|
data/bin/cql_ruby
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'cql_ruby'
|
4
|
+
|
5
|
+
def show_help
|
6
|
+
puts <<~HELP
|
7
|
+
|
8
|
+
\tSYNOPSIS
|
9
|
+
\tcql_ruby options pattern path filters ...
|
10
|
+
|
11
|
+
\tDESCRIPTION
|
12
|
+
\tCQL (Code Query Language) is a semantic search tool for your Ruby source code.
|
13
|
+
|
14
|
+
\tFILTERS
|
15
|
+
\t\tParent node type: type:T(,T)*
|
16
|
+
|
17
|
+
\tOPTIONS
|
18
|
+
\t\t-nc (--no-color) No color on output.
|
19
|
+
\t\t-nf (--no-file) No file names.
|
20
|
+
\t\t-ns (--no-source) No source code.
|
21
|
+
|
22
|
+
\tEXAMPLES
|
23
|
+
\tcql_ruby -ns update_user_info ./ type:send,arg
|
24
|
+
HELP
|
25
|
+
|
26
|
+
exit
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [Hash{Symbol->Boolean}]
|
30
|
+
def extract_options
|
31
|
+
options = {
|
32
|
+
show_color: true,
|
33
|
+
show_file: true,
|
34
|
+
show_source: true,
|
35
|
+
}
|
36
|
+
|
37
|
+
ARGV.delete_if do |arg|
|
38
|
+
if arg[0] == '-'
|
39
|
+
if %w[-nc --no-color].include?(arg)
|
40
|
+
options[:show_color] = false
|
41
|
+
elsif %w[-nf --no-file].include?(arg)
|
42
|
+
options[:show_file] = false
|
43
|
+
elsif %w[-ns --no-source].include?(arg)
|
44
|
+
options[:show_source] = false
|
45
|
+
elsif %w[-h --help]
|
46
|
+
show_help
|
47
|
+
else
|
48
|
+
raise "Unknown arg #{arg}"
|
49
|
+
end
|
50
|
+
|
51
|
+
true
|
52
|
+
else
|
53
|
+
false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
options
|
58
|
+
end
|
59
|
+
|
60
|
+
# @return [Array]
|
61
|
+
def extract_filters
|
62
|
+
ARGV.take(ARGV.size)
|
63
|
+
end
|
64
|
+
|
65
|
+
begin
|
66
|
+
options = extract_options
|
67
|
+
|
68
|
+
raise unless ARGV.size >= 2
|
69
|
+
|
70
|
+
pattern = ARGV.shift
|
71
|
+
# TODO Make path patterns universal.
|
72
|
+
path = ARGV.shift
|
73
|
+
|
74
|
+
# Rest must be filters - can sink ARGV now.
|
75
|
+
filters = extract_filters
|
76
|
+
filter_reader = CqlRuby::FilterReader.new(filters)
|
77
|
+
|
78
|
+
printer = CqlRuby::ConsolePrinter.new
|
79
|
+
printer.color_on = options[:show_color]
|
80
|
+
printer.file_on = options[:show_file]
|
81
|
+
printer.source_on = options[:show_source]
|
82
|
+
|
83
|
+
collector = CqlRuby::CrumbCollector.new(printer)
|
84
|
+
CqlRuby::Executor.new(collector, filter_reader, pattern, path, filters).search_all
|
85
|
+
rescue => e
|
86
|
+
puts "Error: #{e}"
|
87
|
+
show_help
|
88
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cql_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- itarato
|
@@ -12,10 +12,12 @@ date: 2020-07-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: it.arato@gmail.com
|
15
|
-
executables:
|
15
|
+
executables:
|
16
|
+
- cql_ruby
|
16
17
|
extensions: []
|
17
18
|
extra_rdoc_files: []
|
18
19
|
files:
|
20
|
+
- bin/cql_ruby
|
19
21
|
- lib/cql_ruby.rb
|
20
22
|
- lib/cql_ruby/abstract_printer.rb
|
21
23
|
- lib/cql_ruby/console_printer.rb
|