-
Notifications
You must be signed in to change notification settings - Fork 0
/
erefs
executable file
·47 lines (42 loc) · 1.05 KB
/
erefs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#! env ruby
# -*- coding: utf-8 -*-
require_relative "erlang"
$human_readable = ARGV.include?("-h")
def print_ref(file_path, mod_name, func_name)
if $human_readable
puts "#{file_path} => #{mod_name}:#{func_name}(...)"
else
puts "#{file_path}:#{mod_name}:#{func_name}"
end
end
if ARGV.length >= 1
query_mod = query_func = nil
if ARGV[0] =~ /([a-zA-Z_][a-zA-Z0-9_]*):([a-z_][a-z0-9_]*)/
query_mod = $1
query_func = $2
else
query = ARGV[0]
end
find_imports.each do |file_path, mod|
mod.each do |mod_name,x|
if query_mod == mod_name
if x.functions.include?(query_func)
print_ref(file_path, query_mod, query_func)
break
end
elsif query
if x.functions.include?(query)
print_ref(file_path, mod_name, query)
break
end
if mod_name == query
x.functions.each do |func_name|
print_ref(file_path, mod_name, func_name)
end
end
end
end
end
else
puts "please enter a module:function or function"
end