OILS / demo / survey-pretty-print.sh View on Github | oilshell.org

81 lines, 20 significant
1#!/usr/bin/env bash
2#
3# Survey pretty printing
4#
5# Usage:
6# demo/survey-pretty-print.sh <function name>
7
8set -o nounset
9set -o pipefail
10set -o errexit
11
12pretty() {
13 # Python doesn't do pretty printing, but we could try this module
14 #
15 # https://github.com/tommikaikkonen/prettyprinter
16
17 echo 'Python'
18 python3 -c '
19d = {}
20for i in range(20):
21 d[i] = i
22
23d[0] = []
24for i in range(30):
25 d[0].append(i)
26
27d[9] = lambda x: x
28
29print(d)
30'
31
32 echo
33
34 # node.js does some line wrapping with color, with console.log().
35 # It might be their own REPL, or built into v8.
36 echo 'JS'
37 nodejs -e '
38var d = {}
39for (var i = 0; i < 20; ++i) {
40 d[i] = i;
41}
42
43d[0] = [];
44for (var i = 0; i < 30; ++i) {
45 d[0].push(i);
46}
47
48d[19] = [];
49for (var i = 0; i < 50; ++i) {
50 d[19].push(i);
51}
52
53d[19][12] = {"k": "v"};
54
55d[9] = function (x) { return x; }
56
57// Causes fancier columns
58d[0][8] = function (x) { return x; }
59
60console.log(d)
61'
62 echo
63
64 # - Do Perl and Ruby do any printing? IRB is Ruby's REPL
65 # - Lua and awk don't do any pretty printing AFAIK
66}
67
68issues() {
69 devtools/release-note.sh fetch-issues
70}
71
72nodejs-issues() {
73 cat _tmp/issues.json | nodejs -e \
74 'var fs = require("fs"); var stdin = fs.readFileSync(0, "utf-8"); console.log(JSON.parse(stdin));'
75}
76
77jq-issues() {
78 cat _tmp/issues.json | jq .
79}
80
81"$@"