From 7e91db8fa22586917fb41a9cf94cdb5dabf2a70a Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Sun, 18 Aug 2024 22:56:43 -0700 Subject: [PATCH] Switch to rust --- .gitignore | 1 + Cargo.lock | 7 +++++ Cargo.toml | 10 +++++++ log2table.awk | 75 --------------------------------------------------- src/main.rs | 3 +++ 5 files changed, 21 insertions(+), 75 deletions(-) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml delete mode 100644 log2table.awk create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..4ea95ca --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "tablify" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..28acdc3 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "tablify" +version = "0.1.0" +edition = "2021" +authors = ["Scott Worley "] +description = "Summarize a text log as an HTML table" +license = "GPL-3.0" +repository = "https://git.scottworley.com/tablify" + +[dependencies] diff --git a/log2table.awk b/log2table.awk deleted file mode 100644 index 5188c81..0000000 --- a/log2table.awk +++ /dev/null @@ -1,75 +0,0 @@ - -# TODO: Implement quoting properly -function quote_html(s) { return s; } -function quote_html_attribute(s) { return gensub("\"", """, "g", s) } - -BEGIN { - FS = ":" - num_rows = 0 - num_cols = 0 - read_header = 1 - # h/t https://wabain.github.io/2019/10/13/css-rotated-table-header.html - print "" -} - -END { - printf "" - for (i=0; i < num_cols; i++) { - printf "", quote_html_attribute(col_headers[i]), quote_html(col_headers[i]) - } - print ""; - for (i=1*skip_rows; i <= num_rows; i++) { - spacer_row = substr(row_headers[i], 1, 1) == "!" - row_header = spacer_row ? substr(row_headers[i], 2) : row_headers[i] - printf "", quote_html_attribute(row_header), quote_html(row_header) - for (j = 0;j < num_cols; j++) { - printf "" - } - print "" - } - print "
%s
%s" rows[i][j] "
" -} - -{ - if (/^$/) { - read_header = 1 - num_rows++ - } else { - if (read_header) { - read_header = 0 - row_headers[num_rows] = $0 - } else { - if (! ($1 in col_index)) { - col_headers[num_cols] = $1 - col_index[$1] = num_cols++ - } - rows[num_rows][col_index[$1]] = $2 ? $2 : " " - } - } -} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} -- 2.44.1