Skip to content

Commit

Permalink
chore: add complex examples in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
morgante committed Mar 21, 2024
1 parent 4ff989e commit 894eae4
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,30 @@ Run `grit check` to enforce your patterns as [custom lints](https://docs.grit.io
grit check
```

## Examples

### Remove all `console.log` calls, unless they are inside a try-catch block

```grit
`console.log($log)` => . where {
$log <: not within `try { $_ } catch { $_ }`
}
```

### Replace a method call with a new method call

```grit
`$instance.oldMethod($args)` => `$instance.newMethod($args)` where {
$program <: contains `$instance = new TargetClass($_)`
}
```

### More examples

Many more examples can be found in the [GritQL standard library](https://github.com/getgrit/stdlib/blob/main/.grit/patterns/).

Patterns can be combined to create complex queries, including [large refactors](https://github.com/getgrit/stdlib/blob/main/.grit/patterns/python/openai.md).

## Why GritQL?

GritQL comes from our experiences with conducting large scale refactors and migrations.
Expand Down

0 comments on commit 894eae4

Please sign in to comment.