Skip to content

Commit f02d329

Browse files
committed
feat!: rewrite in Rust
Bump the version to 3.0.0. All command line functionality should be preserved. However, this is not *quite* a refactor because some functionality has changed: 1. The input file argument is optional. If no input file path is given or it is "-", csv2html reads from the standard input. 2. There are more newlines in the output HTML. I think this improves how the output looks. 3. The CSV parser may work differently from Python's. It does not break anything for me and parses my data indentically. Please report if it breaks something for you. Most of the tests remain in Python.
1 parent 36f3965 commit f02d329

22 files changed

+775
-274
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
*.egg*
55
*.pyc
66
*.sublime-*
7+
8+
/target/

Cargo.lock

+263
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "csv2html"
3+
version = "3.0.0"
4+
authors = ["D. Bohdan"]
5+
edition = "2018"
6+
7+
[dependencies]
8+
clap = "2.33"
9+
csv = "1.1"
10+
exitcode = "1.1.2"
11+
snafu = "0.6.8"

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2013, 2014, 2017 dbohdan.
1+
Copyright (c) 2013, 2014, 2017, 2020 D. Bohdan.
22
All rights reserved.
33

44
Redistribution and use in source and binary forms, with or without modification,

Makefile

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
BUILD_USER ?= $(USER)
2+
USER_TEMP ?= /tmp/$(BUILD_USER)
3+
PROJECT_TEMP ?= $(USER_TEMP)/csv2html-rust
4+
TARGET ?= x86_64-unknown-linux-musl
5+
BUILD_OPTS ?= --target $(TARGET)
6+
BUILD_OPTS_WITH_DIR ?= $(BUILD_OPTS) --target-dir $(PROJECT_TEMP)
7+
8+
dev: temp-dir
9+
# A workaround for https://github.com/rust-lang/rust/issues/46981
10+
find Cargo.* src/ tests/ | entr -r sh -c 'cargo check $(BUILD_OPTS_WITH_DIR) < /dev/null'
11+
12+
debug: temp-dir
13+
cargo build $(BUILD_OPTS_WITH_DIR)
14+
15+
install:
16+
install $(PROJECT_TEMP)/$(TARGET)/release/csv2html /usr/local/bin
17+
strip /usr/local/bin/csv2html
18+
19+
release: temp-dir
20+
cargo build $(BUILD_OPTS_WITH_DIR) --release
21+
22+
temp-dir:
23+
@-mkdir -m 0700 $(USER_TEMP)/ 2> /dev/null
24+
@-mkdir $(PROJECT_TEMP)/ 2> /dev/null
25+
26+
test: test-unit test-integration
27+
28+
test-integration: debug
29+
CSV2HTML_COMMAND="$(PROJECT_TEMP)/$(TARGET)/debug/csv2html" python3 tests/test_csv2html.py
30+
31+
test-unit:
32+
cargo test $(BUILD_OPTS_WITH_DIR)
33+
34+
uninstall:
35+
rm /usr/local/bin/csv2html
36+
37+
PHONY: dev install release temp-dir test test-integration test-unit uninstall

csv2html/__init__.py

-4
This file was deleted.

0 commit comments

Comments
 (0)