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
|
# File 'lib/rbs/cli/diff.rb', line 6
def initialize(argv:, library_options:, stdout: $stdout, stderr: $stderr)
@format = nil
@stdout = stdout
@stderr = stderr
type_name = nil
library_options = library_options
before_path = []
after_path = []
detail = false
opt = OptionParser.new do |o|
o.banner = <<~HELP
[Experimental] This command is experimental. API and output compatibility is not guaranteed.
Usage:
rbs diff --format markdown --type-name Foo --before before_sig --after after_sig
Print diff for rbs environment dir
Examples:
# Diff dir1 and dir2 for Foo
$ rbs diff --format markdown --type-name Foo --before dir1 --after dir2
# Confirmation of methods related to Time class added by including stdlib/time
$ rbs diff --format diff --type-name Time --after stdlib/time
HELP
o.on("--format NAME") { |arg| @format = arg }
o.on("--type-name NAME") { |arg| type_name = arg }
o.on("--before DIR") { |arg| before_path << arg }
o.on("--after DIR") { |arg| after_path << arg }
o.on("--[no-]detail") { |arg| detail = arg }
end
opt.parse!(argv)
unless @format && type_name && ["markdown", "diff"].include?(@format)
@stderr.puts opt.banner
exit 1
end
@diff = RBS::Diff.new(
type_name: TypeName(type_name).absolute!,
library_options: library_options,
after_path: after_path,
before_path: before_path,
detail: detail,
)
end
|