Class: Tapioca::Cli
- Inherits:
-
Thor
- Object
- Thor
- Tapioca::Cli
- Includes:
- CliHelper, ConfigHelper, EnvHelper
- Defined in:
- lib/tapioca/cli.rb
Constant Summary collapse
- FILE_HEADER_OPTION_DESC =
"Add a \"This file is generated\" header on top of each generated RBI file"
Instance Attribute Summary
Attributes included from ConfigHelper
Instance Method Summary collapse
- #__print_version ⇒ Object
- #annotations ⇒ Object
- #check_shims ⇒ Object
- #configure ⇒ Object
- #dsl(*constants) ⇒ Object
- #gem(*gems) ⇒ Object
- #init ⇒ Object
- #require ⇒ Object
- #todo ⇒ Object
Methods included from EnvHelper
Methods included from ConfigHelper
Methods included from CliHelper
#netrc_file, #rbi_formatter, #say_error
Instance Method Details
#__print_version ⇒ Object
327 328 329 |
# File 'lib/tapioca/cli.rb', line 327 def __print_version puts "Tapioca v#{Tapioca::VERSION}" end |
#annotations ⇒ Object
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
# File 'lib/tapioca/cli.rb', line 307 def annotations if ![:netrc] && [:netrc_file] raise Thor::Error, set_color("Options `--no-netrc` and `--netrc-file` can't be used together", :bold, :red) end command = Commands::Annotations.new( central_repo_root_uris: [:sources], auth: [:auth], netrc_file: netrc_file(), typed_overrides: [:typed_overrides], ) Tapioca.silence_warnings do command.execute end end |
#check_shims ⇒ Object
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/tapioca/cli.rb', line 279 def check_shims command = Commands::CheckShims.new( gem_rbi_dir: [:gem_rbi_dir], dsl_rbi_dir: [:dsl_rbi_dir], shim_rbi_dir: [:shim_rbi_dir], annotations_rbi_dir: [:annotations_rbi_dir], todo_rbi_file: [:todo_rbi_file], payload: [:payload], number_of_workers: [:workers], ) Tapioca.silence_warnings do command.execute end end |
#configure ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/tapioca/cli.rb', line 38 def configure command = Commands::Configure.new( sorbet_config: SORBET_CONFIG_FILE, tapioca_config: [:config], default_postrequire: [:postrequire], ) command.execute end |
#dsl(*constants) ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/tapioca/cli.rb', line 130 def dsl(*constants) set_environment() command = Commands::Dsl.new( requested_constants: constants, outpath: Pathname.new([:outdir]), only: [:only], exclude: [:exclude], file_header: [:file_header], tapioca_path: TAPIOCA_DIR, should_verify: [:verify], quiet: [:quiet], verbose: [:verbose], number_of_workers: [:workers], rbi_formatter: rbi_formatter(), app_root: [:app_root], ) Tapioca.silence_warnings do if [:list_compilers] command.list_compilers else command.execute end end end |
#gem(*gems) ⇒ Object
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/tapioca/cli.rb', line 231 def gem(*gems) Tapioca.silence_warnings do set_environment() all = [:all] verify = [:verify] command = Commands::Gem.new( gem_names: all ? [] : gems, exclude: [:exclude], prerequire: [:prerequire], postrequire: [:postrequire], typed_overrides: [:typed_overrides], outpath: Pathname.new([:outdir]), file_header: [:file_header], include_doc: [:doc], include_loc: [:loc], include_exported_rbis: [:exported_gem_rbis], number_of_workers: [:workers], auto_strictness: [:auto_strictness], dsl_dir: [:dsl_dir], rbi_formatter: rbi_formatter(), ) raise MalformattedArgumentError, "Options '--all' and '--verify' are mutually exclusive" if all && verify unless gems.empty? raise MalformattedArgumentError, "Option '--all' must be provided without any other arguments" if all raise MalformattedArgumentError, "Option '--verify' must be provided without any other arguments" if verify end if gems.empty? && !all command.sync(should_verify: verify, exclude: [:exclude]) else command.execute end end end |
#init ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/tapioca/cli.rb', line 27 def init invoke(:configure) invoke(:annotations) invoke(:gem) invoke(:todo) print_init_next_steps end |
#require ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/tapioca/cli.rb', line 49 def require command = Commands::Require.new( requires_path: [:postrequire], sorbet_config_path: SORBET_CONFIG_FILE, ) Tapioca.silence_warnings do command.execute end end |
#todo ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/tapioca/cli.rb', line 68 def todo command = Commands::Todo.new( todo_file: [:todo_file], file_header: [:file_header], ) Tapioca.silence_warnings do command.execute end end |