Handle CLI arguments as structured argument-parameter pairs

This commit is contained in:
Juno Takano 2025-12-14 15:08:55 -03:00
commit 2040854e82
7 changed files with 83 additions and 15 deletions

View file

@ -3,7 +3,9 @@ use axum::{
http::{Response, StatusCode, header, HeaderValue},
};
use crate::formats::{Format, populate_graph, serialize_graph};
use crate::{
formats::{Format, populate_graph, serialize_graph},
};
use crate::handlers;
pub async fn file(file_path: &str, content_type: &str) -> Response<Body> {

View file

@ -1,16 +1,14 @@
use axum::{body::Body, extract::Path, http::Response};
use crate::{formats::populate_graph, types::Node, handlers};
use crate::{formats::populate_graph, handlers, types::Node};
pub async fn node(Path(id): Path<String>) -> Response<Body> {
let mut context = tera::Context::new();
let graph = populate_graph();
let nodes = graph.nodes;
let empty_node =
Node::new(Some(format!("Could not find node with ID {id}.")));
let empty_node = Node::new(Some(format!("Could not find node ID {id}.")));
let node: &Node = nodes.get(&id).unwrap_or(&empty_node);
let node: &Node = graph.nodes.get(&id).unwrap_or(&empty_node);
context.insert("id", &id);
context.insert("title", &node.title);