what is going on uhhhhhh
This commit is contained in:
Generated
+1
@@ -1316,6 +1316,7 @@ dependencies = [
|
|||||||
"axum-extra",
|
"axum-extra",
|
||||||
"color-eyre",
|
"color-eyre",
|
||||||
"futures",
|
"futures",
|
||||||
|
"lda-ipjs",
|
||||||
"macaddr",
|
"macaddr",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_html_form",
|
"serde_html_form",
|
||||||
|
|||||||
@@ -36,3 +36,6 @@ very-smart-parsing = [
|
|||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["ipjs"]
|
members = ["ipjs"]
|
||||||
|
|
||||||
|
[dependencies.lda-ipjs]
|
||||||
|
path = "ipjs"
|
||||||
|
|||||||
@@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
// prefix seems to be a cidr. both 6 and 4 works. idfk dog
|
// 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");
|
let mut cmd = tokio::process::Command::new("ip");
|
||||||
cmd.args(["-j", "address", "show"]);
|
cmd.args(["-j", "address", "show"]);
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
// 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
|
// it all turns to live osstr tho so ts just for my own sanity
|
||||||
// thiserror? anyhow
|
// 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(
|
pub async fn get(
|
||||||
ip: Option<IpAddr>,
|
ip: Option<IpAddr>,
|
||||||
dev: Option<&str>,
|
dev: Option<&str>,
|
||||||
@@ -23,8 +27,7 @@ pub async fn get(
|
|||||||
};
|
};
|
||||||
|
|
||||||
if let Some(dev) = dev {
|
if let Some(dev) = dev {
|
||||||
cmd.arg("dev");
|
cmd.args(["dev", dev]);
|
||||||
cmd.arg(dev);
|
|
||||||
}
|
}
|
||||||
for nud in nud {
|
for nud in nud {
|
||||||
cmd.arg("nud");
|
cmd.arg("nud");
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
//! this is purely experimental. im not doing ts no mo
|
||||||
|
|
||||||
// hallo
|
// hallo
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
|
|||||||
+46
-7
@@ -36,6 +36,8 @@ def indent(text: str, n: int) -> str:
|
|||||||
|
|
||||||
|
|
||||||
class RsAsset(ABC):
|
class RsAsset(ABC):
|
||||||
|
path: Path
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def plain(self) -> str: ...
|
def plain(self) -> str: ...
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
@@ -64,8 +66,8 @@ class RsAssetFile(RsAsset):
|
|||||||
|
|
||||||
|
|
||||||
class RsAssetModule(RsAsset):
|
class RsAssetModule(RsAsset):
|
||||||
def __init__(self, folder: Path, body_only: bool = False):
|
def __init__(self, path: Path, body_only: bool = False):
|
||||||
self.folder = folder
|
self.path = path
|
||||||
self.full = not body_only
|
self.full = not body_only
|
||||||
|
|
||||||
plain_template = "pub mod {sanitized_name} {{\n{indented_body}\n}}"
|
plain_template = "pub mod {sanitized_name} {{\n{indented_body}\n}}"
|
||||||
@@ -85,7 +87,7 @@ class RsAssetModule(RsAsset):
|
|||||||
if not self.full:
|
if not self.full:
|
||||||
return body
|
return body
|
||||||
return template.format(
|
return template.format(
|
||||||
sanitized_name=sanitize(self.folder.name).lower(),
|
sanitized_name=sanitize(self.path.name).lower(),
|
||||||
indented_body=indent(body, 4),
|
indented_body=indent(body, 4),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -95,7 +97,7 @@ class RsAssetModule(RsAsset):
|
|||||||
|
|
||||||
def iterate_assets(self) -> Iterable[RsAsset]:
|
def iterate_assets(self) -> Iterable[RsAsset]:
|
||||||
subs = []
|
subs = []
|
||||||
for f in self.folder.iterdir():
|
for f in self.path.iterdir():
|
||||||
if f.is_file():
|
if f.is_file():
|
||||||
yield RsAssetFile(f)
|
yield RsAssetFile(f)
|
||||||
elif f.is_dir():
|
elif f.is_dir():
|
||||||
@@ -103,6 +105,39 @@ class RsAssetModule(RsAsset):
|
|||||||
yield from subs
|
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 = """
|
lda_macro = """
|
||||||
macro_rules! hehe {
|
macro_rules! hehe {
|
||||||
// Folder
|
// Folder
|
||||||
@@ -124,11 +159,11 @@ macro_rules! hehe {
|
|||||||
header = "// generated with ./scripts/map_static.py"
|
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]:
|
def wpr[**P, R](f: Callable[P, R]) -> Callable[P, R]:
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
def wpd(*a: P.args, **k: P.kwargs) -> R:
|
def wpd(*a: P.args, **k: P.kwargs) -> R:
|
||||||
print(what)
|
print(*pa, **pkw)
|
||||||
return f(*a, **k)
|
return f(*a, **k)
|
||||||
|
|
||||||
return wpd
|
return wpd
|
||||||
@@ -138,7 +173,11 @@ def announce_yourself(what: str):
|
|||||||
|
|
||||||
class RsAssetRoot(RsAsset):
|
class RsAssetRoot(RsAsset):
|
||||||
def __init__(self, asset: Path) -> None:
|
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")
|
@announce_yourself("generating code macro style")
|
||||||
def macroed(self):
|
def macroed(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user