Radish alpha
r
Radicle terminal user interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Add file logger
Erik Kundt committed 2 years ago
commit 0ed7bb61e43675ad4bf3f6e7c9279632f035cf21
parent 337570a5a107de8902f865da13fa3eb003e8cbd5
3 files changed +45 -19
modified Cargo.lock
@@ -1328,9 +1328,11 @@ version = "0.1.0"
dependencies = [
 "anyhow",
 "lexopt",
+
 "log",
 "radicle",
 "radicle-surf",
 "radicle-term",
+
 "simple-logging",
 "textwrap 0.16.0",
 "timeago",
 "tui-realm-stdlib",
@@ -1409,6 +1411,12 @@ dependencies = [

[[package]]
name = "redox_syscall"
+
version = "0.1.57"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
+

+
[[package]]
+
name = "redox_syscall"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
@@ -1605,6 +1613,17 @@ dependencies = [
]

[[package]]
+
name = "simple-logging"
+
version = "2.0.2"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "b00d48e85675326bb182a2286ea7c1a0b264333ae10f27a937a72be08628b542"
+
dependencies = [
+
 "lazy_static",
+
 "log",
+
 "thread-id",
+
]
+

+
[[package]]
name = "siphasher"
version = "0.3.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1829,6 +1848,17 @@ dependencies = [
]

[[package]]
+
name = "thread-id"
+
version = "3.3.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "c7fbf4c9d56b320106cd64fd024dadfa0be7cb4706725fc44a7d7ce952d820c1"
+
dependencies = [
+
 "libc",
+
 "redox_syscall 0.1.57",
+
 "winapi",
+
]
+

+
[[package]]
name = "time"
version = "0.1.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
modified Cargo.toml
@@ -13,6 +13,8 @@ path = "src/main.rs"
[dependencies]
anyhow = { version = "1" }
lexopt = { version = "0.2" }
+
log = { version = "0.4.19" }
+
simple-logging = { version = "2.0.2" }
radicle = { version = "0.2.0" }
radicle-term = { version = "0.1.0" }
radicle-surf = { version = "0.14.0" }
@@ -20,15 +22,3 @@ timeago = { version = "0.4.1" }
textwrap = { version = "0.16.0" }
tuirealm = { version = "1.8.0", default-features = false, features = [ "with-termion" ] }
tui-realm-stdlib = { version = "1.2.0", default-features = false, features = [ "with-termion" ] }
-

-
# [dependencies.radicle]
-
# version = "0"
-
# path = "../heartwood/radicle"
-

-
# [dependencies.radicle-cli]
-
# version = "0"
-
# path = "../heartwood/radicle-cli"
-

-
# [dependencies.radicle-term]
-
# version = "0"
-
# path = "../heartwood/radicle-term"
modified src/main.rs
@@ -1,7 +1,10 @@
use std::process;

use anyhow::{anyhow, Context};
+
use log::info;
+
use log::LevelFilter;

+
use radicle::profile;
use radicle::{
    crypto::ssh::keystore::MemorySigner, prelude::Signer, profile::env::RAD_PASSPHRASE, Profile,
};
@@ -85,18 +88,21 @@ fn execute() -> anyhow::Result<()> {

    let (_, id) = radicle::rad::cwd()
        .map_err(|_| anyhow!("this command must be run in the context of a project"))?;
-

    let profile = profile()?;
-

    let signer = signer(&profile)?;
-
    let storage = &profile.storage;
-

-
    let payload = storage
+
    let payload = &profile
+
        .storage
        .get(signer.public_key(), id)?
        .context("No project with such `id` exists")?;
-

    let project = payload.project()?;

+
    let logfile = format!(
+
        "{}/radicle-tui.log",
+
        profile::home()?.path().to_string_lossy()
+
    );
+
    simple_logging::log_to_file(logfile, LevelFilter::Info)?;
+
    info!("Launching window...");
+

    let mut window = Window::default();
    window.run(&mut app::App::new(profile, id, project), 1000 / FPS)?;

@@ -105,7 +111,7 @@ fn execute() -> anyhow::Result<()> {

fn main() {
    if let Err(err) = execute() {
-
        term::error(format!("Error: rad-tui: {err}"));
+
        term::error(format!("Error: radicle-tui: {err}"));
        process::exit(1);
    }
}