-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy patharg-scanner
executable file
·79 lines (65 loc) · 2.35 KB
/
arg-scanner
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env ruby
require 'optparse'
require 'arg_scanner/options'
require 'arg_scanner/version'
options = ArgScanner::OPTIONS
option_parser = OptionParser.new do |opts|
opts.banner = "arg-scanner #{ArgScanner::VERSION}" + <<~EOB
Usage: arg-scanner [OPTIONS] <ruby cmdline>
arg-scanner is a ruby script mediator supposed to be run from the command line or IDE.
The data will be sent to a signature server so it must be running during arg-scanner execution.
EOB
opts.separator "Options:"
opts.on("--type-tracker", "enable type tracker") do
options.enable_type_tracker = true
end
opts.on("--state-tracker", "enable state tracker") do
options.enable_state_tracker = true
end
opts.on("--no-type-tracker", "disable type tracker") do
options.enable_type_tracker = false
end
opts.on("--no-state-tracker", "disable state tracker") do
options.enable_state_tracker = false
end
opts.on("--output-dir=[Dir]", String, "specify output directory (ignored by type tracker)") do |dir|
options.output_dir = dir
end
opts.on("--catch-only-every-N-call=[N]", Integer, "randomly catches only 1/N of all calls to speed up performance (by default N = 1)") do |n|
options.catch_only_every_n_call = n
end
opts.on("--project-root=[PATH]", String, "Specify project's root directory to catch every call from this directory. "\
"Calls from other directories aren't guaranteed to be caught") do |path|
options.project_root = path
end
opts.on("--pipe-file-path=[PATH]", String, "Specify pipe file path to connect to server") do |path|
options.pipe_file_path = path
end
opts.on("--buffering", "enable buffering between arg-scanner and server. It speeds up arg-scanner but doesn't allow "\
"to use arg-scanner \"interactively\". Disabled by default") do |buffering|
options.buffering = buffering
end
end
begin
option_parser.parse! ARGV
rescue StandardError => e
puts option_parser
puts
puts e.message
exit 1
end
if ARGV.size < 1
puts option_parser
puts
puts "Ruby program to trace must be specified."
exit 1
end
options.set_env
old_opts = ENV['RUBYOPT'] || ''
starter = "-r #{File.expand_path(File.dirname(__FILE__))}/../lib/arg_scanner/starter"
unless old_opts.include? starter
ENV['RUBYOPT'] = starter
ENV['RUBYOPT'] += " #{old_opts}" if old_opts != ''
end
$0 = ARGV[0]
Kernel.exec *ARGV