Skip to content

Commit e1b4441

Browse files
ahogappamame
authored andcommitted
feat: add --init option
It generate typeprof config file
1 parent 1fa5c00 commit e1b4441

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

lib/typeprof/cli/cli.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def initialize(argv)
1111

1212
output = nil
1313
rbs_collection_path = nil
14+
initialize_config_file = false
1415

1516
opt.separator ""
1617
opt.separator "Options:"
@@ -39,6 +40,7 @@ def initialize(argv)
3940
opt.separator ""
4041
opt.separator "Advanced options:"
4142
opt.on("--[no-]stackprof MODE", /\Acpu|wall|object\z/, "Enable stackprof (for debugging purpose)") {|v| cli_options[:stackprof] = v.to_sym }
43+
opt.on("--init", 'Generate TypeProf configuration file') {|v| initialize_config_file = true}
4244

4345
opt.separator ""
4446
opt.separator "LSP options:"
@@ -47,6 +49,11 @@ def initialize(argv)
4749

4850
opt.parse!(argv)
4951

52+
if initialize_config_file
53+
generate_config_file
54+
exit 0
55+
end
56+
5057
if !cli_options[:lsp] && !lsp_options.empty?
5158
raise OptionParser::InvalidOption.new("lsp options with non-lsp mode")
5259
end
@@ -175,5 +182,9 @@ def set_profiler
175182
StackProf.results
176183
end
177184
end
185+
186+
def generate_config_file
187+
File.write('typeprof.conf.jsonc', File.read(File.join(__dir__, 'typeprof.conf.jsonc')))
188+
end
178189
end
179190
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"typeprof_version": "experimental",
3+
"rbs_dir": "sig/"
4+
// "analysis_unit_dirs": [],
5+
// "diagnostic_severity": "warning"
6+
}

0 commit comments

Comments
 (0)