Skip to content

Conversation

@sanket1729
Copy link
Member

Adds methods to pretty print policies similar to directory tree printing in Linux. Prints diff in colors which highlights the differences between the two policies.

Our representation of Semantic policies in only in Thresh, so we combine or(pk,or(pk,pk)) into thresh(1,pk,pk,pk). And so we use the latter in comparing two policies that complicate some of the implementation but is still fairly small.

(x, y) => {
let red = "\x1b[0;31m";
let nc = "\x1b[0m";
let green = "\x1b[0;32m";
Copy link
Member

Choose a reason for hiding this comment

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

I think we need to come up with a different encoding scheme. It doesn't have to be pretty, we could provide a shellscript or something that converted it into a colorized version.

But using shell escape sequences means that we won't work on windows and are likely to confuse other command line tools.

sanket1729 added a commit to sanket1729/rust-miniscript that referenced this pull request Oct 1, 2021
e829434 Implemented Policy Diff (sanket1729)
4d23b79 Pretty print a policy (sanket1729)

Pull request description:

  Adds methods to pretty print policies similar to directory tree printing in Linux. Prints diff in colors which highlights the differences between the two policies.

  Our representation of Semantic policies in only in Thresh, so we combine `or(pk,or(pk,pk))` into `thresh(1,pk,pk,pk)`. And so we use the latter in comparing two policies that complicate some of the implementation but is still fairly small.

Top commit has no ACKs.

Tree-SHA512: 8efd11b2c2582a4e26455ccb718d1ad2016ead3507746bd98a16240c7c72cf411df7fa01d817aee3a42c138b8ff7b887e7104d29d15f7a57a61620eee20a9d2b
}

/// Pretty Print a tree
pub fn pprint_tree(&self) {
Copy link
Member

Choose a reason for hiding this comment

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

In 4d23b79:

Can we make this pub(crate)? I think we can come up with a much better API here and I'd rather not expose this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants