what is going on uhhhhhh

This commit is contained in:
lda
2025-12-02 16:54:09 +07:00 Unverified
parent c3486527de
commit 2cb65d7ee6
6 changed files with 59 additions and 11 deletions
Generated
+1
View File
@@ -1316,6 +1316,7 @@ dependencies = [
"axum-extra",
"color-eyre",
"futures",
"lda-ipjs",
"macaddr",
"serde",
"serde_html_form",
+3
View File
@@ -36,3 +36,6 @@ very-smart-parsing = [
[workspace]
members = ["ipjs"]
[dependencies.lda-ipjs]
path = "ipjs"
+2 -2
View File
@@ -19,9 +19,9 @@
// prefix seems to be a cidr. both 6 and 4 works. idfk dog
use super::AddrInfo;
use super::AddrOutput;
pub async fn get(dev: Option<&str>) -> anyhow::Result<Vec<AddrInfo>> {
pub async fn get(dev: Option<&str>) -> anyhow::Result<Vec<AddrOutput>> {
let mut cmd = tokio::process::Command::new("ip");
cmd.args(["-j", "address", "show"]);
+5 -2
View File
@@ -10,6 +10,10 @@ use super::{NUDState, NeighborItem};
// i think ill write tokio::process every time tho (for this if let thing) because iterate through all ts youll have to as str and all the hooplas.
// it all turns to live osstr tho so ts just for my own sanity
// thiserror? anyhow
// what is vro sayin
// ahh. instead of using [wakey::utils::cmd::exec_command] which is ass we jus write everything out. so i dont have to .as_str() so often.
pub async fn get(
ip: Option<IpAddr>,
dev: Option<&str>,
@@ -23,8 +27,7 @@ pub async fn get(
};
if let Some(dev) = dev {
cmd.arg("dev");
cmd.arg(dev);
cmd.args(["dev", dev]);
}
for nud in nud {
cmd.arg("nud");
+2
View File
@@ -1,3 +1,5 @@
//! this is purely experimental. im not doing ts no mo
// hallo
use std::{
collections::{HashMap, HashSet},
+46 -7
View File
@@ -36,6 +36,8 @@ def indent(text: str, n: int) -> str:
class RsAsset(ABC):
path: Path
@abstractmethod
def plain(self) -> str: ...
@abstractmethod
@@ -64,8 +66,8 @@ class RsAssetFile(RsAsset):
class RsAssetModule(RsAsset):
def __init__(self, folder: Path, body_only: bool = False):
self.folder = folder
def __init__(self, path: Path, body_only: bool = False):
self.path = path
self.full = not body_only
plain_template = "pub mod {sanitized_name} {{\n{indented_body}\n}}"
@@ -85,7 +87,7 @@ class RsAssetModule(RsAsset):
if not self.full:
return body
return template.format(
sanitized_name=sanitize(self.folder.name).lower(),
sanitized_name=sanitize(self.path.name).lower(),
indented_body=indent(body, 4),
)
@@ -95,7 +97,7 @@ class RsAssetModule(RsAsset):
def iterate_assets(self) -> Iterable[RsAsset]:
subs = []
for f in self.folder.iterdir():
for f in self.path.iterdir():
if f.is_file():
yield RsAssetFile(f)
elif f.is_dir():
@@ -103,6 +105,39 @@ class RsAssetModule(RsAsset):
yield from subs
# i meant plain
def render_pain(ass: RsAsset) -> str:
"""
fym i have to deal with all RsAsset subclasses
whats the point then. unless there is a `Intermediate Representation` whats the point then.
"""
match ass:
case RsAssetFile() as file:
return file.apply_template(file.plain_template)
case RsAssetModule() as folder:
return folder.apply_template(folder.plain_template, render_pain)
case RsAssetRoot() as r:
return r.plain()
case _:
raise TypeError("who are you?")
def render_macro(ass: RsAsset) -> str:
"""
ts is ridiculous
"""
match ass:
case RsAssetFile() as file:
return file.apply_template(file.macroed_template)
case RsAssetModule() as folder:
return folder.apply_template(folder.macroed_template, render_macro)
case RsAssetRoot() as r:
return r.macroed()
case _:
raise TypeError("who are you?")
lda_macro = """
macro_rules! hehe {
// Folder
@@ -124,11 +159,11 @@ macro_rules! hehe {
header = "// generated with ./scripts/map_static.py"
def announce_yourself(what: str):
def announce_yourself(*pa, **pkw):
def wpr[**P, R](f: Callable[P, R]) -> Callable[P, R]:
@wraps(f)
def wpd(*a: P.args, **k: P.kwargs) -> R:
print(what)
print(*pa, **pkw)
return f(*a, **k)
return wpd
@@ -138,7 +173,11 @@ def announce_yourself(what: str):
class RsAssetRoot(RsAsset):
def __init__(self, asset: Path) -> None:
self.a = RsAssetModule(asset, True)
self.path = asset
@property
def a(self):
return RsAssetModule(self.path, True)
@announce_yourself("generating code macro style")
def macroed(self):