From: Scott Worley Date: Mon, 19 Aug 2024 05:56:43 +0000 (-0700) Subject: Switch to rust X-Git-Tag: v0.2.0~24 X-Git-Url: http://git.scottworley.com/tablify/commitdiff_plain/7e91db8fa22586917fb41a9cf94cdb5dabf2a70a?hp=ede6233355b70ac831aa79949e0b396ba6320b99 Switch to rust --- 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!"); +}