forked from vectordotdev/vector
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcue.sh
More file actions
executable file
·76 lines (57 loc) · 1.3 KB
/
cue.sh
File metadata and controls
executable file
·76 lines (57 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env bash
set -euo pipefail
# cue.sh
#
# SUMMARY
#
# CUE utilities.
cd "$(dirname "${BASH_SOURCE[0]}")/.."
list-docs-files() {
find docs -name '*.cue'
}
cmd_list() {
list-docs-files
}
cmd_fmt() {
list-docs-files | xargs cue fmt "$@"
}
cmd_vet() {
list-docs-files | xargs cue vet --concrete --all-errors "$@"
}
cmd_eval() {
list-docs-files | xargs cue eval --concrete --all-errors "$@"
}
cmd_export() {
list-docs-files | xargs cue export --all-errors "$@"
}
usage() {
cat >&2 <<-EOF
Usage: $0 MODE
Modes:
list - list all the documentation files
fmt - format all the documentation files
vet - check the documentation files and print errors
eval - print the evaluated documentation,
optionally pass the expression to evaluate via "-e EXPRESSION"
export - export the documentation,
optionally pass the expression to evaluate via "-e EXPRESSION"
Examples:
Print the whole documentation in the JSON format:
$0 export
Print the "components.sources.kubernetes_logs" subtree in CUE format:
$0 eval -e components.sources.kubernetes_logs
Print the "cli" subtree in JSON format:
$0 export -e cli
EOF
exit 1
}
MODE="${1:-}"
case "$MODE" in
list|fmt|vet|eval|export)
shift
"cmd_$MODE" "$@"
;;
*)
usage
;;
esac