Skip to content

Commit d8b198b

Browse files
committed
docs: Add 'bobject.print' to README and example script
1 parent 7936bad commit d8b198b

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ assert [ ${#REPLY[@]} -eq 4 ]
4545

4646
bobject get-string --value root_object '.["zulu"].["yankee"].["xray"].["foxtrot"].[2]'
4747
assert [ "$REPLY" = rho ]
48+
49+
bobject.print 'root_object'
50+
# |__ zulu (__bash_object_root_object___zulu_24092_8313_29963_14301_14535)
51+
# |__ yankee (__bash_object_root_object___zulu_yankee_15383_14163_12814_23488_13779)
52+
# |__ xray (__bash_object_root_object___zulu_yankee_xray_18071_28791_7790_539_19231)
53+
# |__ whiskey
54+
# |__ foxtrot (__bash_object_root_object___zulu_yankee_xray_foxtrot_26606_15833_10655_7208_16587)
55+
# |- omicron
56+
# |- pi
57+
# |- rho
58+
# |- sigma
4859
```
4960

5061
## Installation

examples/basalt.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[package]
2+
name = ''
3+
slug = ''
4+
version = ''
5+
authors = []
6+
description = ''
7+
8+
[run]
9+
dependencies = ['https://github.com/hyperupcall/bash-object.git@7936badc984fc56c1aa7e2c940e5e382923146d7']
10+
sourceDirs = []
11+
builtinDirs = []
12+
binDirs = []
13+
completionDirs = []
14+
manDirs = []
15+
16+
[run.shellEnvironment]
17+
18+
[run.setOptions]
19+
20+
[run.shoptOptions]

examples/script.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env bash
2+
set -eo pipefail
3+
4+
# Necessary for Basalt to load dependencies
5+
eval "$(basalt-package-init)"
6+
basalt.package-init
7+
basalt.package-load
8+
9+
10+
declare -A root_object=()
11+
declare -A zulu_object=()
12+
declare -A yankee_object=()
13+
declare -A xray_object=([whiskey]=victor)
14+
declare -a foxtrot_array=(omicron pi rho sigma)
15+
16+
bobject set-object --ref root_object '.zulu' zulu_object
17+
bobject set-object --ref root_object '.zulu.yankee' yankee_object
18+
bobject set-object --ref root_object '.zulu.yankee.xray' xray_object
19+
bobject set-array --ref root_object '.zulu.yankee.xray.foxtrot' foxtrot_array
20+
21+
bobject get-object --value root_object '.zulu.yankee.xray'
22+
printf '%s - %s\n' "${REPLY[whiskey]}" victor
23+
24+
bobject get-string --value root_object '.zulu.yankee.xray.whiskey'
25+
printf '%s - %s\n' "$REPLY" victor
26+
27+
bobject get-array --value root_object '.zulu.yankee.xray.foxtrot'
28+
printf '%d - %d\n' ${#REPLY[@]} 4
29+
30+
bobject get-string --value root_object '.["zulu"].["yankee"].["xray"].["foxtrot"].[2]'
31+
printf '%s - %s\n' "$REPLY" rho
32+
33+
bobject.print 'root_object'

0 commit comments

Comments
 (0)