Skip to content

Commit d7b5729

Browse files
docs(examples): add example scripts for orcid-works-cli (#8)
1 parent bed5a5b commit d7b5729

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

examples/orcid-works/filter.jq

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# a) 0th: edit title & backdate last-modified-date (→ to be updated)
2+
(.records[0].title.title.value) |= "Title to be updated"
3+
| (.records[0]."last-modified-date".value) -= 86400000
4+
# b) 1st) duplicate and change title & put-code (→ to be deleted)
5+
| .records += [.records[1]]
6+
| (.records[1]."put-code") |= 999999
7+
| (.records[1].title.title.value) |= "Title to be deleted"
8+
# c) 2nd: remove (→ to be added)
9+
| del(.records[2])

examples/orcid-works/test.ps1

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env pwsh
2+
3+
# 0) set your ORCID ID or sample ID
4+
$ORCID_ID = "0000-0002-1825-0097"
5+
6+
# 1) initial fetch
7+
cargo run -p orcid-works-cli -- -i "$ORCID_ID" -o output.json
8+
9+
# 2) mangle the JSON (requires at least 3 records)
10+
jq -f filter.jq output.json > output-modified.json
11+
Copy-Item output-modified.json -Destination output-modified-1.json
12+
Copy-Item output-modified.json -Destination output-modified-2.json
13+
14+
# 3) refetch (diff-aware)
15+
cargo run -p orcid-works-cli -- -i "$ORCID_ID" -o output-modified-1.json
16+
# => only missing/changed records are fetched
17+
18+
# 3') force-fetch (bypass diff)
19+
cargo run -p orcid-works-cli -- -i "$ORCID_ID" -o output-modified-2.json --force-fetch
20+
# => all records are fetched
21+
22+
# 4) compare results (expected: identical)
23+
Compare-Object output.json output-modified-1.json
24+
Compare-Object output.json output-modified-2.json

examples/orcid-works/test.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
3+
# 0) set your ORCID ID or sample ID
4+
ORCID_ID="0000-0002-1825-0097"
5+
6+
# 1) initial fetch
7+
cargo run -p orcid-works-cli -- -i "$ORCID_ID" -o output.json
8+
9+
# 2) mangle the JSON (requires at least 3 records)
10+
jq -f filter.jq output.json > output-modified.json
11+
cp output-modified.json output-modified-1.json
12+
cp output-modified.json output-modified-2.json
13+
14+
# 3) refetch (diff-aware)
15+
cargo run -p orcid-works-cli -- -i "$ORCID_ID" -o output-modified-1.json
16+
# => only missing/changed records are fetched
17+
18+
# 3') force-fetch (bypass diff)
19+
cargo run -p orcid-works-cli -- -i "$ORCID_ID" -o output-modified-2.json --force-fetch
20+
# => all records are fetched
21+
22+
# 4) compare results (expected: identical)
23+
diff -q output.json output-modified-1.json
24+
diff -q output.json output-modified-2.json

0 commit comments

Comments
 (0)