1 | #!/usr/bin/env bash
|
2 | #
|
3 | # Survey pretty printing
|
4 | #
|
5 | # Usage:
|
6 | # demo/survey-pretty-print.sh <function name>
|
7 |
|
8 | set -o nounset
|
9 | set -o pipefail
|
10 | set -o errexit
|
11 |
|
12 | pretty() {
|
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 '
|
19 | d = {}
|
20 | for i in range(20):
|
21 | d[i] = i
|
22 |
|
23 | d[0] = []
|
24 | for i in range(30):
|
25 | d[0].append(i)
|
26 |
|
27 | d[9] = lambda x: x
|
28 |
|
29 | print(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 '
|
38 | var d = {}
|
39 | for (var i = 0; i < 20; ++i) {
|
40 | d[i] = i;
|
41 | }
|
42 |
|
43 | d[0] = [];
|
44 | for (var i = 0; i < 30; ++i) {
|
45 | d[0].push(i);
|
46 | }
|
47 |
|
48 | d[19] = [];
|
49 | for (var i = 0; i < 50; ++i) {
|
50 | d[19].push(i);
|
51 | }
|
52 |
|
53 | d[19][12] = {"k": "v"};
|
54 |
|
55 | d[9] = function (x) { return x; }
|
56 |
|
57 | // Causes fancier columns
|
58 | d[0][8] = function (x) { return x; }
|
59 |
|
60 | console.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 |
|
68 | issues() {
|
69 | devtools/release-note.sh fetch-issues
|
70 | }
|
71 |
|
72 | nodejs-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 |
|
77 | jq-issues() {
|
78 | cat _tmp/issues.json | jq .
|
79 | }
|
80 |
|
81 | "$@"
|