cli: `rad seed` output improvement

Better colors, and re-order fields to have policy before scope.
This commit is contained in:
cloudhead 2024-02-21 12:12:20 +01:00
parent 0908c65f50
commit e06dd208f4
No known key found for this signature in database
6 changed files with 20 additions and 15 deletions

View File

@ -36,8 +36,8 @@ And a 'block' policy was added:
```
$ rad seed
╭───────────────────────────────────────────────────────╮
│ RID Scope Policy
│ Repository Policy Scope
├───────────────────────────────────────────────────────┤
│ rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji followed block
│ rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji block followed │
╰───────────────────────────────────────────────────────╯
```

View File

@ -35,9 +35,9 @@ repository that was already created:
```
$ rad seed
╭───────────────────────────────────────────────────────╮
│ RID Scope Policy
│ Repository Policy Scope
├───────────────────────────────────────────────────────┤
│ rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji followed allow
│ rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji allow followed
╰───────────────────────────────────────────────────────╯
```

View File

@ -30,8 +30,8 @@ We can list the repositories we are seeding by omitting the RID:
```
$ rad seed
╭───────────────────────────────────────────────────────╮
│ RID Scope Policy
│ Repository Policy Scope
├───────────────────────────────────────────────────────┤
│ rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji followed allow
│ rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji allow followed
╰───────────────────────────────────────────────────────╯
```

View File

@ -177,9 +177,9 @@ pub fn seeding(profile: &Profile) -> anyhow::Result<()> {
let store = profile.policies()?;
let mut t = term::Table::new(term::table::TableOptions::bordered());
t.header([
term::format::default(String::from("RID")),
term::format::default(String::from("Scope")),
term::format::default(String::from("Repository")),
term::format::default(String::from("Policy")),
term::format::default(String::from("Scope")),
]);
t.divider();
@ -191,13 +191,9 @@ pub fn seeding(profile: &Profile) -> anyhow::Result<()> {
{
let id = id.to_string();
let scope = scope.to_string();
let policy = policy.to_string();
let policy = term::format::policy(&policy);
t.push([
term::format::highlight(id),
term::format::secondary(scope),
term::format::secondary(policy),
])
t.push([term::format::tertiary(id), policy, term::format::dim(scope)])
}
if t.is_empty() {

View File

@ -7,6 +7,7 @@ pub use radicle_term::{style, Paint};
use radicle::cob::{ObjectId, Timestamp};
use radicle::identity::Visibility;
use radicle::node::policy::Policy;
use radicle::node::{Alias, AliasStore, NodeId};
use radicle::prelude::Did;
use radicle::profile::Profile;
@ -63,6 +64,14 @@ pub fn visibility(v: &Visibility) -> Paint<&str> {
}
}
/// Format a policy.
pub fn policy(p: &Policy) -> Paint<String> {
match p {
Policy::Allow => term::format::positive(p.to_string()),
Policy::Block => term::format::negative(p.to_string()),
}
}
/// Format a timestamp.
pub fn timestamp(time: impl Into<LocalTime>) -> Paint<String> {
let time: LocalTime = time.into();

View File

@ -86,7 +86,7 @@ pub struct Limits {
/// How long to keep a gossip message entry before pruning it.
#[serde(with = "crate::serde_ext::localtime::duration")]
pub gossip_max_age: LocalDuration,
/// Maximum number of concurrent fetches per per connection.
/// Maximum number of concurrent fetches per peer connection.
pub fetch_concurrency: usize,
/// Maximum number of open files.
pub max_open_files: usize,