-
Notifications
You must be signed in to change notification settings - Fork 616
WIP: teams #3334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
WIP: teams #3334
Conversation
To allow re-use for private override.
crates/cli/src/subcommands/delete.rs
Outdated
pub fn print_database_tree_info(&self, mut out: impl io::Write) -> anyhow::Result<()> { | ||
let fmt_names = |names: &BTreeSet<String>| match names.len() { | ||
0 => <_>::default(), | ||
1 => format!(": {}", names.first().unwrap()), | ||
_ => format!(": {names:?}"), | ||
}; | ||
|
||
let tree_info = &self.database_tree; | ||
|
||
write!(out, "{}{}", tree_info.root.identity, fmt_names(&tree_info.root.names))?; | ||
for (identity, info) in &tree_info.children { | ||
let names = fmt_names(&info.names); | ||
let parent = info | ||
.parent | ||
.map(|parent| format!(" (parent: {parent})")) | ||
.unwrap_or_default(); | ||
|
||
write!(out, "{identity}{parent}{names}")?; | ||
} | ||
|
||
Ok(()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aasoni I have been a little un-imaginative about how to render the tree of children when trying to delete a parent. Note also that a database can have more than one name.
If you have a specific idea of how this should be rendered, please let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe @bfops ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just getting to this. I think it's fine to do "something" and improve it later if we feel strongly about it. This isn't a very common subcommand in people's workflows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have changed this to render a tree (like the tree
command), unless --yes
is given:
0000000000000000000000000000000000000000000000000000000000000001: parent
├── 0000000000000000000000000000000000000000000000000000000000000004: bro, sibling
└── 0000000000000000000000000000000000000000000000000000000000000002: child
├── 0000000000000000000000000000000000000000000000000000000000000005
└── 0000000000000000000000000000000000000000000000000000000000000003: grandchild
We could abbreviate the identities if, and only if, there are no collisions. I'll leave that as a future exercise.
WIP