rbs icon indicating copy to clipboard operation
rbs copied to clipboard

Add -e, --type, and --method-type options to `rbs parse` command

Open pocke opened this issue 3 years ago • 0 comments

I propose adding -e option and so on to rbs parse command.

Why

Currently we need to put a .rbs file in order to run a syntax check. It is not convenient.

# prepare a temporary file with the content I want to check
$ echo 'class Foo def x: () -> void end' > test.rbs

# Run syntax check
$ rbs parse test.rbs

# Clear the temporary file
$ rm test.rbs

So I propose adding the options to rbs parse command. We will can avoid putting a file by this change.

# We can run the syntax check out of the box.
$ rbs parse -e 'class Foo def x: () -> void end'

# It calls `RBS::Parser.parse_type` instead.
# We can focus on the code we want to check by reducing wrapper such as `class Foo .... end`
$ rbs parse --type -e 'Foo::Bar'

# It calls `RBS::Parser.parse_method_type` instead.
# It has the same benefit as `--type` option.
$ rbs parse --method-type -e '() -> void'

pocke avatar Mar 17 '22 07:03 pocke