cli: Show repo visibility in `rad ls`
This commit is contained in:
parent
befc76e030
commit
ba5ed58997
|
|
@ -48,9 +48,9 @@ $ rad sync rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu --fetch
|
|||
✓ Fetching rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu from z6MknSL…StBU8Vi..
|
||||
✓ Fetched repository from 1 seed(s)
|
||||
$ rad ls --private
|
||||
╭──────────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ Name RID Head Description │
|
||||
├──────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ heartwood rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu f2de534 radicle heartwood protocol & stack │
|
||||
╰──────────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ Name RID Visibility Head Description │
|
||||
├───────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ heartwood rad:z2ug5mwNKZB8KGpBDRTrWHAMbvHCu private f2de534 radicle heartwood protocol & stack │
|
||||
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
```
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ Projects can be listed with the `ls` command:
|
|||
|
||||
```
|
||||
$ rad ls
|
||||
╭──────────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ Name RID Head Description │
|
||||
├──────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ heartwood rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji f2de534 Radicle Heartwood Protocol & Stack │
|
||||
╰──────────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ Name RID Visibility Head Description │
|
||||
├───────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ heartwood rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji public f2de534 Radicle Heartwood Protocol & Stack │
|
||||
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
```
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ First let's look at what we have locally:
|
|||
|
||||
```
|
||||
$ rad ls
|
||||
╭──────────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ Name RID Head Description │
|
||||
├──────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ heartwood rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji f2de534 Radicle Heartwood Protocol & Stack │
|
||||
╰──────────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────╮
|
||||
│ Name RID Visibility Head Description │
|
||||
├───────────────────────────────────────────────────────────────────────────────────────────────────────────┤
|
||||
│ heartwood rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji public f2de534 Radicle Heartwood Protocol & Stack │
|
||||
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯
|
||||
```
|
||||
|
||||
Now let's delete the `heartwood` project:
|
||||
|
|
|
|||
|
|
@ -203,13 +203,9 @@ pub fn init(options: Options, profile: &profile::Profile) -> anyhow::Result<()>
|
|||
term::headline(format!(
|
||||
"Initializing{}radicle 👾 project in {}",
|
||||
if let Some(visibility) = &options.visibility {
|
||||
if !visibility.is_public() {
|
||||
term::format::yellow(" private ")
|
||||
} else {
|
||||
term::format::positive(" public ")
|
||||
}
|
||||
term::format::spaced(term::format::visibility(visibility))
|
||||
} else {
|
||||
term::format::default(" ")
|
||||
term::format::default(" ").into()
|
||||
},
|
||||
if path == cwd {
|
||||
term::format::tertiary(".").to_string()
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
|||
table.push([
|
||||
"Name".into(),
|
||||
"RID".into(),
|
||||
"Visibility".into(),
|
||||
"Head".into(),
|
||||
"Description".into(),
|
||||
]);
|
||||
|
|
@ -92,12 +93,14 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
|||
if !doc.visibility.is_public() && !options.private && options.public {
|
||||
continue;
|
||||
}
|
||||
let proj = doc.verified()?.project()?;
|
||||
let doc = doc.verified()?;
|
||||
let proj = doc.project()?;
|
||||
let head = term::format::oid(head).into();
|
||||
|
||||
table.push([
|
||||
term::format::bold(proj.name().to_owned()),
|
||||
term::format::tertiary(rid.urn()),
|
||||
term::format::visibility(&doc.visibility).into(),
|
||||
term::format::secondary(head),
|
||||
term::format::italic(proj.description().to_owned()),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ pub use radicle_term::format::*;
|
|||
pub use radicle_term::{style, Paint};
|
||||
|
||||
use radicle::cob::{ObjectId, Timestamp};
|
||||
use radicle::identity::Visibility;
|
||||
use radicle::node::{Alias, AliasStore, NodeId};
|
||||
use radicle::prelude::Did;
|
||||
use radicle::profile::Profile;
|
||||
|
|
@ -30,6 +31,11 @@ pub fn parens<D: fmt::Display>(input: Paint<D>) -> Paint<String> {
|
|||
Paint::new(format!("({})", input.item)).with_style(input.style)
|
||||
}
|
||||
|
||||
/// Wrap spaces around styled input, eg. `"input"` -> `" input "`.
|
||||
pub fn spaced<D: fmt::Display>(input: Paint<D>) -> Paint<String> {
|
||||
Paint::new(format!(" {} ", input.item)).with_style(input.style)
|
||||
}
|
||||
|
||||
/// Format a command suggestion, eg. `rad init`.
|
||||
pub fn command<D: fmt::Display>(cmd: D) -> Paint<String> {
|
||||
primary(format!("`{cmd}`"))
|
||||
|
|
@ -46,6 +52,14 @@ pub fn did(did: &Did) -> Paint<String> {
|
|||
Paint::new(format!("{}…{}", &nid[..7], &nid[nid.len() - 7..]))
|
||||
}
|
||||
|
||||
/// Format a Visibility.
|
||||
pub fn visibility(v: &Visibility) -> Paint<&str> {
|
||||
match v {
|
||||
Visibility::Public => term::format::positive("public"),
|
||||
Visibility::Private { .. } => term::format::secondary("private"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Remove html style comments from a string.
|
||||
///
|
||||
/// The html comments must start at the beginning of a line and stop at the end.
|
||||
|
|
|
|||
Loading…
Reference in New Issue