Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Multiple rewrites in a single command. #327

Open
Sintrastes opened this issue Dec 13, 2021 · 1 comment
Open

Feature request: Multiple rewrites in a single command. #327

Sintrastes opened this issue Dec 13, 2021 · 1 comment

Comments

@Sintrastes
Copy link

Consider the following sequence of comby re-writes used to refactor an Option-like data structure to just using nullable types in

comby 'AlertResult<:[x]>' ':[x]?' -in-place .kt
comby 'AlertResult.Ok(:[x])' ':[x]' -in-place .kt
comby 'AlertResult.Canceled()' 'null' -in-place .kt

It would be convenient if we could write this like the following, so that the -in-place and .kt pieces don't have to be repeated, and we can use a single command:

comby 'AlertResult<:[x]>' ':[x]?' \
   'AlertResult.Ok(:[x])' ':[x]' \
   'AlertResult.Canceled()' 'null' -in-place .kt
@rvantonder
Copy link
Member

rvantonder commented Jan 9, 2022

The closest thing to achieve this right now is via a config file. This doesn't give the convenience of a command line though. A sequence of anonymous arguments like in the single command you put is tricky to support, because there are some other assumptions on what the shape of anonymous arguments mean.

A better solution is to express multiple rewrites in a single command, where that command is a script in a comby DSL, which is something I've made some progress on, but unlikely to happen very very soon. You can imagine something like this, where can sequence multiple x -> y rewrites with ;

comby -script 'AlertResult<:[x]> -> :[x]?; AlertResult.Ok(:[x]) -> :[x]; AlertResult.Canceled() -> null' .kt

This would also supersede the more heavy/awkward config files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants