Skip to content

Commit 8abe297

Browse files
committed
readme update
1 parent fc52821 commit 8abe297

File tree

1 file changed

+39
-31
lines changed

1 file changed

+39
-31
lines changed

README.md

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ Prerequisite: jdk11+
2525
* [Regular Scala REPL](#regular-scala-repl)
2626
* [Ammonite](#ammonite)
2727
* [scala-cli](#scala-cli)
28+
- [Prerequisite for all of the below: run `sbt stage` or download the latest release](#prerequisite-for-all-of-the-below-run-sbt-stage-or-download-the-latest-release)
2829
- [REPL](#repl)
30+
* [run with defaults](#run-with-defaults)
31+
* [customize prompt, greeting and exit code](#customize-prompt-greeting-and-exit-code)
32+
* [execute some predef code](#execute-some-predef-code)
2933
* [Operators: Redirect to file, pipe to external command](#operators-redirect-to-file-pipe-to-external-command)
3034
* [Add dependencies with maven coordinates](#add-dependencies-with-maven-coordinates)
3135
* [Importing additional script files interactively](#importing-additional-script-files-interactively)
@@ -59,7 +63,7 @@ Prerequisite: jdk11+
5963
* [Updating the Scala version](#updating-the-scala-version)
6064
* [Updating the shaded libraries](#updating-the-shaded-libraries)
6165
- [Fineprint](#fineprint)
62-
66+
6367
## Benefits over / comparison with
6468

6569
### Regular Scala REPL
@@ -87,27 +91,31 @@ Stock Scala REPL:<br/>
8791
* srp has a 66.6% shorter name :slightly_smiling_face:
8892
scala-cli wraps and invokes the regular Scala REPL (by default; or optionally Ammonite). It doesn't modify/fix the REPL itself, i.e. the above mentioned differences between srp and the stock scala repl (or alternatively Ammonite) apply, with the exception of dependencies: scala-cli does let you add them on startup as well.
8993

94+
## Prerequisite for all of the below: run `sbt stage` or download the latest release
95+
9096
## REPL
9197

98+
### run with defaults
9299
```bash
93-
# run with defaults
94-
srp
100+
./srp
101+
```
95102

96-
# customize prompt, greeting and exit code
97-
srp --prompt myprompt --greeting 'hey there!' --onExitCode 'println("see ya!")'
103+
### customize prompt, greeting and exit code
104+
./srp --prompt myprompt --greeting 'hey there!' --onExitCode 'println("see ya!")'
98105

99-
# pass some predef code in file(s)
106+
### execute some predef code
107+
```
100108
echo 'def foo = 42' > foo.sc
101109
102-
srp --predef foo.sc
110+
./srp --predef foo.sc
103111
scala> foo
104112
val res0: Int = 42
105113
```
106114

107115
### Operators: Redirect to file, pipe to external command
108116
Inspired by unix shell redirection and pipe operators (`>`, `>>` and `|`) you can redirect output into files with `#>` (overrides existing file) and `#>>` (create or append to file), and use `#|` to pipe the output to a command, such as `less`:
109117
```scala
110-
srp
118+
./srp
111119

112120
scala> "hey there" #> "out.txt"
113121
scala> "hey again" #>> "out.txt"
@@ -162,7 +170,7 @@ All operators are prefixed with `#` in order to avoid naming clashes with more b
162170
### Add dependencies with maven coordinates
163171
Note: the dependencies must be known at startup time, either via `--dep` parameter:
164172
```
165-
srp --dep com.michaelpollmeier:versionsort:1.0.7
173+
./srp --dep com.michaelpollmeier:versionsort:1.0.7
166174
scala> versionsort.VersionHelper.compare("1.0", "0.9")
167175
val res0: Int = 1
168176
```
@@ -172,15 +180,15 @@ Alternatively, use the `//> using dep` directive in predef code or predef files:
172180
```
173181
echo '//> using dep com.michaelpollmeier:versionsort:1.0.7' > predef.sc
174182
175-
srp --predef predef.sc
183+
./srp --predef predef.sc
176184
177185
scala> versionsort.VersionHelper.compare("1.0", "0.9")
178186
val res0: Int = 1
179187
```
180188

181189
For Scala dependencies use `::`:
182190
```
183-
srp --dep com.michaelpollmeier::colordiff:0.36
191+
./srp --dep com.michaelpollmeier::colordiff:0.36
184192
185193
colordiff.ColorDiff(List("a", "b"), List("a", "bb"))
186194
// color coded diff
@@ -194,7 +202,7 @@ Implementation note: srp uses [coursier](https://get-coursier.io/) to fetch the
194202
```
195203
echo 'val bar = "foo"' > myScript.sc
196204
197-
srp
205+
./srp
198206
199207
//> using file myScript.sc
200208
println(bar) //foo
@@ -219,7 +227,7 @@ cd ..
219227

220228
Now let's start the repl with those in the classpath:
221229
```bash
222-
srp --classpathEntry foo
230+
./srp --classpathEntry foo
223231

224232
scala> new Foo().foo
225233
val res0: Int = 42
@@ -230,14 +238,14 @@ For scripts you can use the `//> using classpath` directive:
230238
echo '//> using classpath foo
231239
println(new Foo().foo)' > myScript.sc
232240

233-
srp --script myScript.sc
241+
./srp --script myScript.sc
234242
```
235243

236244
### Rendering of output
237245

238246
Unlike the stock Scala REPL, srp does _not_ truncate the output by default. You can optionally specify the maxHeight parameter though:
239247
```
240-
srp --maxHeight 5
248+
./srp --maxHeight 5
241249
scala> (1 to 100000).toSeq
242250
val res0: scala.collection.immutable.Range.Inclusive = Range(
243251
1,
@@ -282,18 +290,18 @@ See [ScriptRunnerTest](core/src/test/scala/replpp/scripting/ScriptRunnerTest.sca
282290
```bash
283291
echo 'println("Hello!")' > test-simple.sc
284292

285-
srp --script test-simple.sc
293+
./srp --script test-simple.sc
286294
cat out.txt # prints 'i was here'
287295
```
288296

289297
### Predef file(s) used in script
290298
```bash
291-
echo 'println(foo)' > test-predef.sc
292299
echo 'val foo = "Hello, predef file"' > test-predef-file.sc
300+
echo 'println(foo)' > test-predef.sc
293301
```
294302

295303
```bash
296-
srp --script test-predef.sc --predef test-predef-file.sc
304+
./srp --script test-predef.sc --predef test-predef-file.sc
297305
```
298306
To import multiple scripts, you can specify this parameter multiple times.
299307

@@ -304,7 +312,7 @@ echo 'val foo = 42' > foo.sc
304312
echo '//> using file foo.sc
305313
println(foo)' > test.sc
306314

307-
srp --script test.sc
315+
./srp --script test.sc
308316
```
309317

310318
### Dependencies
@@ -318,7 +326,7 @@ assert(compareResult == 1,
318326
s"result of comparison should be `1`, but was `$compareResult`")
319327
' > test-dependencies.sc
320328

321-
srp --script test-dependencies.sc
329+
./srp --script test-dependencies.sc
322330
```
323331

324332
Note: this also works with `using` directives in your predef code - for script and REPL mode.
@@ -327,7 +335,7 @@ Note: this also works with `using` directives in your predef code - for script a
327335
```bash
328336
echo '@main def main() = println("Hello, world!")' > test-main.sc
329337

330-
srp --script test-main.sc
338+
./srp --script test-main.sc
331339
```
332340

333341
### multiple @main entrypoints
@@ -337,7 +345,7 @@ echo '
337345
@main def bar() = println("bar!")
338346
' > test-main-multiple.sc
339347

340-
srp --script test-main-multiple.sc --command foo
348+
./srp --script test-main-multiple.sc --command foo
341349
```
342350

343351
### named parameters
@@ -347,7 +355,7 @@ echo '
347355
println(s"Hello, $first $last!")
348356
} ' > test-main-withargs.sc
349357

350-
srp --script test-main-withargs.sc --param first=Michael --param last=Pollmeier
358+
./srp --script test-main-withargs.sc --param first=Michael --param last=Pollmeier
351359
```
352360
If your parameter value contains whitespace, just wrap it quotes so that your shell doesn't split it up, e.g. `--param "text=value with whitespace"`
353361

@@ -357,7 +365,7 @@ On windows the parameters need to be triple-quoted in any case:
357365
## Additional dependency resolvers and credentials
358366
Via `--repo` parameter on startup:
359367
```bash
360-
srp --repo "https://repo.gradle.org/gradle/libs-releases" --dep org.gradle:gradle-tooling-api:7.6.1
368+
./srp --repo "https://repo.gradle.org/gradle/libs-releases" --dep org.gradle:gradle-tooling-api:7.6.1
361369
scala> org.gradle.tooling.GradleConnector.newConnector()
362370
```
363371
To add multiple dependency resolvers, you can specify this parameter multiple times.
@@ -371,7 +379,7 @@ echo '
371379
println(org.gradle.tooling.GradleConnector.newConnector())
372380
' > script-with-resolver.sc
373381

374-
srp --script script-with-resolver.sc
382+
./srp --script script-with-resolver.sc
375383
```
376384

377385
If one or multiple of your resolvers require authentication, you can configure your username/passwords in a [`credentials.properties` file](https://get-coursier.io/docs/other-credentials#property-file):
@@ -391,14 +399,14 @@ The prefix is arbitrary and is only used to specify several credentials in a sin
391399
For the REPL itself:
392400
```
393401
export JAVA_OPTS='-Xdebug -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y'
394-
srp
402+
./srp
395403
unset JAVA_OPTS
396404
```
397405
Then attach your favorite IDE / debugger on port 5005.
398406

399407
If you want to debug a script, it's slightly different. Scripts are executed in a separate subprocess - just specify the following parameter (and make sure `JAVA_OPTS` isn't also set).
400408
```
401-
srp --script myScript.sc --remoteJvmDebug
409+
./srp --script myScript.sc --remoteJvmDebug
402410
```
403411

404412
## Server mode
@@ -418,7 +426,7 @@ curl http://localhost:8080/query-sync -X POST -d '{"query":"println(\"OMG remote
418426

419427
The same for windows and powershell:
420428
```
421-
srp-server.bat
429+
./srp-server.bat
422430
423431
Invoke-WebRequest -Method 'Post' -Uri http://localhost:8080/query-sync -ContentType "application/json" -Body '{"query": "val foo = 42"}'
424432
# Content : {"success":true,"stdout":"val foo: Int = 42\r\n","uuid":"02f843ba-671d-4fb5-b345-91c1dcf5786d"}
@@ -552,10 +560,10 @@ While maven central jar releases are created for each commit on master (a new ve
552560
cd /path/to/dotty
553561
git fetch
554562

555-
OLD=3.3.0 # set to version that was used before you bumped it
556-
NEW=3.3.1 # set to version that you bumped it to
563+
OLD=3.4.2 # set to version that was used before you bumped it
564+
NEW=3.5.2-RC2 # set to version that you bumped it to
557565
git checkout $NEW
558-
git diff $OLD compiler/src/dotty/tools/repl
566+
git diff $OLD..$NEW compiler/src/dotty/tools/repl
559567
```
560568
* check if any of those changes need to be reapplied to this repo
561569

0 commit comments

Comments
 (0)