[Fix] moved language to logging

This commit is contained in:
Alex Emmet 2026-04-08 11:36:42 +02:00
commit b37ec732f7
7 changed files with 46 additions and 29 deletions

View file

@ -4,7 +4,11 @@ version = "0.1.0"
edition = "2024" edition = "2024"
[dependencies] [dependencies]
ratatui = "0.30.0"
ttp-core = { git = "https://git.methanium.net/Tensamin/TTP.git", package = "ttp-core" }
iota-state = { path = "../iota-state" } iota-state = { path = "../iota-state" }
iota-util = { path = "../iota-util" } iota-util = { path = "../iota-util" }
ttp-core = { git = "https://git.methanium.net/Tensamin/TTP.git", package = "ttp-core" }
ratatui = "0.30.0"
json = "0.12.4"
once_cell = "1.21.4"

View file

@ -1,4 +1,5 @@
use crate::file_util::save_file; use iota_util::file_util::save_file;
use json::{self, JsonError, JsonValue}; use json::{self, JsonError, JsonValue};
pub fn create_languages() -> Result<(), JsonError> { pub fn create_languages() -> Result<(), JsonError> {

View file

@ -1,4 +1,4 @@
use crate::file_util::{self}; use iota_util::file_util::{self};
use json::parse; use json::parse;
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use std::collections::HashMap; use std::collections::HashMap;

View file

@ -12,7 +12,8 @@ use ratatui::style::Color;
use ttp_core::{CommunicationValue, DataTypes, DataValue}; use ttp_core::{CommunicationValue, DataTypes, DataValue};
use iota_state::{APP_STATE, UNIQUE, UiLogEntry}; use iota_state::{APP_STATE, UNIQUE, UiLogEntry};
use iota_util::langu::language_manager; mod language_creator;
mod language_manager;
static LOGGER: OnceLock<mpsc::Sender<LogMessage>> = OnceLock::new(); static LOGGER: OnceLock<mpsc::Sender<LogMessage>> = OnceLock::new();
@ -128,22 +129,6 @@ fn fixed_box(content: &str, width: usize) -> String {
} }
} }
fn colorize(kind: PrintType, is_error: bool) -> Color {
if is_error {
return Color::Red;
}
match kind {
PrintType::Call => Color::Magenta,
PrintType::Client => Color::Green,
PrintType::Iota => Color::Yellow,
PrintType::Omikron => Color::Blue,
PrintType::Omega => Color::Cyan,
PrintType::General => Color::LightCyan,
PrintType::Command => Color::LightGreen,
}
}
pub fn log_internal_translated( pub fn log_internal_translated(
kind: PrintType, kind: PrintType,
prefix: String, prefix: String,

0
iota-updater/Cargo.toml Normal file
View file

View file

@ -5,7 +5,6 @@
use anyhow::{Context, Result, anyhow}; use anyhow::{Context, Result, anyhow};
use semver::Version; use semver::Version;
use serde::Deserialize;
use std::fs::File; use std::fs::File;
use std::io::copy; use std::io::copy;
use tempfile::NamedTempFile; use tempfile::NamedTempFile;
@ -16,13 +15,13 @@ const API_BASE: &str = "https://git.methanium.net/api/v1";
const OWNER: &str = "Tensamin"; const OWNER: &str = "Tensamin";
const REPO: &str = "Iota"; const REPO: &str = "Iota";
#[derive(Debug, Deserialize)] #[derive(Debug)]
struct Release { struct Release {
tag_name: String, tag_name: String,
assets: Vec<Asset>, assets: Vec<Asset>,
} }
#[derive(Debug, Deserialize)] #[derive(Debug)]
struct Asset { struct Asset {
name: String, name: String,
browser_download_url: String, browser_download_url: String,
@ -39,10 +38,40 @@ async fn latest_release() -> Result<Release> {
return Err(anyhow!("release API returned {}", response.status())); return Err(anyhow!("release API returned {}", response.status()));
} }
Ok(response let text = response
.json() .text()
.await .await
.context("failed to parse release JSON")?) .context("failed to read response text")?;
let parsed = json::parse(&text).map_err(|e| anyhow!("failed to parse JSON: {}", e))?;
let tag_name = parsed["tag_name"]
.as_str()
.ok_or_else(|| anyhow!("missing tag_name"))?
.to_string();
let assets_json = parsed["assets"].members().collect::<Vec<_>>();
let mut assets = Vec::new();
for asset in assets_json {
let name = asset["name"]
.as_str()
.ok_or_else(|| anyhow!("missing asset name"))?
.to_string();
let browser_download_url = asset["browser_download_url"]
.as_str()
.ok_or_else(|| anyhow!("missing download url"))?
.to_string();
assets.push(Asset {
name,
browser_download_url,
});
}
Ok(Release { tag_name, assets })
} }
async fn parse_tag_version(tag: &str) -> Result<Version> { async fn parse_tag_version(tag: &str) -> Result<Version> {

View file

@ -1,2 +0,0 @@
pub mod language_creator;
pub mod language_manager;