Skip to content

carton rbs

Writes RBS for what each import returns, so Steep or another type checker can type the values imports bind. See Types and checks for how to use it.

Usage: carton rbs [options] PATH...
-I, --include DIR Add DIR to the load path for named imports
--exclude GLOB Skip matching files in directory PATHs (and vendor/bundle)
-o, --output FILE Where to write the RBS (default sig/generated/carton.rbs, - for stdout)
--check Exit 1 if the output file is missing or stale; write nothing
-h, --help Show this help
-v, --version Show the version
Option Effect
-I, --include DIR Add DIR to the load path for named imports. Repeatable.
--exclude GLOB Skip files in a directory PATH whose path relative to it, or a parent directory’s, matches GLOB, such as tmp or **/fixtures. Repeatable. **/vendor/bundle is always skipped. Files reached by imports are still read
-o, --output FILE Where to write the RBS: sig/generated/carton.rbs by default, or - for stdout
--check Compare the RBS with the output file instead of writing it. Exit 1 if the file is missing or stale, naming the first line that differs. Use it in CI
-h, --help Print this usage to stdout and exit 0
-v, --version Print the version to stdout and exit 0

The file types what each import returns:

  • An exported constant, such as export Billing, as singleton(::Billing). The Carton declares Billing in its own RBS, as a gem would.
  • A keyword export as a record, such as { version: ::String }.
  • An export whose type cannot be inferred statically as untyped.
  • Each literal import path as a Kernel#import or Kernel#import_relative overload, so a local variable bound to an import is typed too. An import_relative path that means different Cartons in different files gets none.
  • Each constant bound to an import, such as Tools = import 'tools', unless the Carton’s own RBS already declares that name.

Writing a file prints Wrote FILE and creates its directory as needed. A file that already holds the same RBS is left untouched and prints FILE is up to date.

0 on success, 1 when --check finds the file missing or stale, and 2 for a usage error or a file that cannot be read or written.