summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2021-08-10 16:38:43 -0700
committerBryan Newbold <bnewbold@archive.org>2021-08-10 16:38:43 -0700
commit808e39e09591b8b69fe542ab3110f761c88a7182 (patch)
treeee1e874f0edced208eb291d81f5f27bd5e2d0c95
parentf1d2e16df3b04d216df28904dc53822bf430c3fb (diff)
downloadfatcat-cli-808e39e09591b8b69fe542ab3110f761c88a7182.tar.gz
fatcat-cli-808e39e09591b8b69fe542ab3110f761c88a7182.zip
entity JSON fetch mode for scholar searches
-rw-r--r--CHANGELOG.md2
-rw-r--r--fatcat-cli/src/main.rs15
2 files changed, 14 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 84111c4..1a38372 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,8 @@
### Added
- basic search for reference index (refs, refs-in, refs-out)
+- `--entity-json` mode for scholar search, returning biblio (primary) release
+ entity
## [0.1.3] - 2021-05-25
diff --git a/fatcat-cli/src/main.rs b/fatcat-cli/src/main.rs
index af22f85..091d073 100644
--- a/fatcat-cli/src/main.rs
+++ b/fatcat-cli/src/main.rs
@@ -661,9 +661,18 @@ fn run(opt: Opt) -> Result<()> {
writeln!(&mut std::io::stdout(), "{}", entity.to_json_string()?)?
}
(false, true, SearchEntityType::Scholar) => {
- return Err(anyhow!(
- "entity schema output not supported for scholar index"
- ));
+ if !hit["biblio"]["release_ident"].is_string() {
+ continue;
+ }
+ let specifier = Specifier::Release(
+ hit["biblio"]["release_ident"].as_str().unwrap().to_string(),
+ );
+ let entity = specifier.get_from_api(
+ &mut api_client,
+ expand.clone(),
+ hide.clone(),
+ )?;
+ writeln!(&mut std::io::stdout(), "{}", entity.to_json_string()?)?
}
(false, true, SearchEntityType::Reference) => {
return Err(anyhow!(