@runfile/cli 1.1.2 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -370,9 +370,11 @@ Line-oriented, with one rule: **the language is the default, the shell is marked
370
370
  | `$ echo hi` | Hand this line to a shell. |
371
371
  | `exec python3` … `end` | Run a command with the block as its stdin. |
372
372
  | `json` … `end` | A block of JSON, as one value. |
373
- | `let x = 1` | Bind a value. `x = 2` rebinds. |
374
- | `if` / `else` / `end` | Branch. |
375
- | `for x in list` / `end` | Loop. |
373
+ | `let x = 1` | Bind a value. `x = 2` rebinds. `let a, b = pair` takes a list apart. |
374
+ | `if` / `else if` / `else` / `end` | Branch. However many `else if`s, one `end`. |
375
+ | `for x in list` / `end` | Loop over a list. `for k, v in pairs` unpacks each item. |
376
+ | `while c` / `until c` / `loop` / `end` | Loop on a condition, on its negation, or forever. |
377
+ | `break` / `continue` | Leave the innermost loop, or start its next pass. |
376
378
  | `match` / `case` / `default` / `end` | Dispatch on a value. A label is a quoted string: `case "linux"`. |
377
379
  | `retry n [every s]` … `end` | Run the block again while it fails, up to `n` times. |
378
380
  | `do` … `end` | A block with no condition, so a property can cover a few commands. |
@@ -387,14 +389,19 @@ Strings, numbers, booleans and lists — **strict, with no coercion.** `"a" + 1`
387
389
  Lists nest as deep as you like, which beats packing several fields into one string and splitting it back out:
388
390
 
389
391
  ```sh
390
- for volume in [
392
+ for volume, owner in [
391
393
  ["prometheus-data", "65534:65534"],
392
394
  ["kvrocks-data", "999:999"],
393
395
  ]
394
- $ docker run --rm -v {{ volume[0] }}:/v alpine chown -R {{ volume[1] }} /v
396
+ $ docker run --rm -v {{ volume }}:/v alpine chown -R {{ owner }} /v
395
397
  end
396
398
  ```
397
399
 
400
+ Several names on the left of a `let`, a reassignment or a `for` take a list apart in order —
401
+ `let major, minor, patch = split(version, ".")` — with `_` for a position you have no use for. A name with
402
+ nothing to bind is an error rather than an empty string, since the names are a claim about the shape of the
403
+ value.
404
+
398
405
  `print` writes a line to stdout; `printf` writes exactly what you give it, with `%s`, `%d`, `%f`, `%.Nf` and
399
406
  `%%`, and no newline of its own.
400
407
 
@@ -404,18 +411,43 @@ Lists are values, and every list function answers with a **new** list, so nothin
404
411
  let recent = slice(reverse(sort(tags)), 0, 5)
405
412
  let targets = without(RUN.namespaces, "docs")
406
413
 
407
- for pair in zip(names, owners)
408
- $ chown {{ pair[1] }} /srv/{{ pair[0] }}
414
+ for name, owner in zip(names, owners)
415
+ $ chown {{ owner }} /srv/{{ name }}
409
416
  end
410
417
  ```
411
418
 
412
419
  `append`, `prepend`, `concat_lists`, `sort`, `reverse`, `unique`, `slice`, `flatten`, `zip`, `index_of` and
413
420
  `without`, beside `first`, `last`, `length` and `join`.
414
421
 
415
- There are 83 built-in functions — strings, lists, regex, paths, JSON, hashes, time, files. Your editor lists
422
+ There are 85 built-in functions — strings, lists, regex, paths, JSON, hashes, time, files. Your editor lists
416
423
  them all with a description and an example; `run :list` is for targets, and the language server is for the
417
424
  language.
418
425
 
426
+ ### Loops
427
+
428
+ `for` walks a list. `while` and `until` ask before each pass — `until` is the shape a wait loop wants — and
429
+ `loop` never asks at all. `break` leaves the innermost one, `continue` starts its next pass, and both are a
430
+ parse error anywhere else, so your editor says so rather than a run finding out.
431
+
432
+ ```sh
433
+ until $ curl -sf http://localhost:8080/health
434
+ sleep(1)
435
+ end
436
+
437
+ for path in glob("**/*.log")
438
+ if !contains(read_file(path), "PANIC")
439
+ continue
440
+ end
441
+
442
+ print("first panic in {{ path }}")
443
+ break
444
+ end
445
+ ```
446
+
447
+ `range(n)` counts from zero and stops short of `n`; `range(a, b)` is every number from `a` to `b`, both
448
+ included. Under `--dry-run` a conditional loop walks its body once: a preview performs none of the effects the
449
+ condition is waiting on, so how often is not a thing it can honestly answer.
450
+
419
451
  ### Where values come from
420
452
 
421
453
  | Source | From |
@@ -607,7 +639,7 @@ Set at the top of the file, or inside a block where marked.
607
639
  | `.watch` | Re-run when matching files change. A `!` prefix excludes. | |
608
640
  | `.alias` | Another name for this target. | |
609
641
  | `.detach` | Start the commands and do not wait. | |
610
- | `.only-in-directories` | For the machine-wide directory: only offer these targets inside these directories. | |
642
+ | `.only-in-directories` | Machine-wide targets only: offer this one inside these directories. Appends. | |
611
643
 
612
644
  `.env-file` and `.add-path` **append**, so a block adds to what it inherited rather than replacing it, and a
613
645
  block's file can be named by something the body worked out — which a header property cannot do, because it
@@ -689,6 +721,23 @@ directory than hide it, `$HOME/runfiles/` and `$HOME/Runfiles/` are read too —
689
721
  hold anything. `run :list` puts them first, under `global:`: they are the part of the listing you cannot see
690
722
  by looking at the project.
691
723
 
724
+ A machine-wide target can say where it belongs, so one directory can hold work for several places at once:
725
+
726
+ ```sh
727
+ # ~/.runfiles/deploy.run
728
+ # Ship the current branch
729
+
730
+ .only-in-directories = ["~/work/acme", "~/work/zed"]
731
+
732
+ $ ./scripts/ship
733
+ ```
734
+
735
+ It is offered inside those directories and nowhere else. A `_shared.run` says the same thing for every target
736
+ below it, and each level narrows the one above — a target cannot name its way back out of a directory that
737
+ excluded it. Relative entries are relative to your home. It is the one property a project's own files may not
738
+ set: their targets are visible to anyone reading the repository, so hiding some by working directory would
739
+ bring back the very invisibility this exists to fix.
740
+
692
741
  **Not in CI.** A runner's home directory is nobody's, so `run` reads none of the three there: what runs is
693
742
  what is checked in and reviewable. This is also why nothing has to be cleaned up after a job.
694
743
 
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/bin/linux-x64/run CHANGED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -14,5 +14,5 @@
14
14
  "license": "MIT",
15
15
  "name": "@runfile/cli",
16
16
  "repository": "https://github.com/JoaaoVerona/runfile",
17
- "version": "1.1.2"
17
+ "version": "1.1.5"
18
18
  }