Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

hc hash --property #1807

Merged
merged 5 commits into from
Oct 28, 2019
Merged

hc hash --property #1807

merged 5 commits into from
Oct 28, 2019

Conversation

lucksus
Copy link
Collaborator

@lucksus lucksus commented Oct 26, 2019

PR summary

Add option "property" to hc hash that sets DNA properties for hash calculation.

USAGE:
    hc hash [OPTIONS]

OPTIONS:
    -p, --path <path>               Path to .dna.json file [default: dist/<dna-name>.dna.json]
    -x, --property <property>...    Property (in the from 'name=value') that gets set/overwritten before calculating
                                    hash

Like so:

[nix-shell:~]$ hc hash --path identity-manager.dna.json --property agent_id=HcSc82gf923hd
Reading DNA from QmZUhssczL8RdBUjKLrtFyV9co2BCHubmJTdj4oeMaUYki.dna.json
DNA Hash: QmWPhCUU3Gib9kTHs2gtiD1VFnwrvqX1zcKFf1WNNnD6mk

followups

Use this in Holoscape to be able to detect installed instances even if they were installed with specific/unique properties (such as identity manager).

changelog

Please check one of the following, relating to the CHANGELOG-UNRELEASED.md

  • this is a code change that effects some consumer (e.g. zome developers) of holochain core so it is added to the CHANGELOG-UNRELEASED.md (linked above), with the format - summary of change [PR#1234](https://github.com/holochain/holochain-rust/pull/1234)
  • this is not a code change, or doesn't effect anyone outside holochain core development

documentation

)));
}
let value = parts.pop().unwrap();
let name = parts.pop().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might be able to shorten this by :
let equal = "=";
let equal_sign= property_string.find(equal).unwrap_or_else(|| Err(err_msg(format!(
"Can't parse property: {}",
property_string
))))?
let (name,value) = property_string.split_at(equal);
map.insert(name,serde_json::Value::String(value.trim_start_matches(equal )))

crates/cli/src/main.rs Outdated Show resolved Hide resolved
@lucksus lucksus merged commit 55ea4f0 into develop Oct 28, 2019
@neonphog neonphog deleted the hc-hash-property branch March 5, 2020 23:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants