build: Makefile

This commit is contained in:
Chen Asraf
2023-05-09 09:04:02 +03:00
parent d52cdb6b57
commit f94a01dc3c
4 changed files with 26 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
[package]
name = "tbl"
name = "tblf"
version = "0.1.0"
edition = "2021"
@@ -10,6 +10,6 @@ strip = true # Automatically strip symbols from the binary.
opt-level = "z" # Optimize for size.
lto = true # link time optimization
codegen-units = 1 # reduce binary size
panic = "abort" # abort on panic
# panic = "abort" # abort on panic
[dependencies]

15
Makefile Normal file
View File

@@ -0,0 +1,15 @@
build:
cargo build --release
build-dev:
cargo build
install:
cp target/release/tblf /usr/local/bin/tblf
install-dev:
cp target/debug/tblf /usr/local/bin/tblf
dev:
make build-dev
make install-dev
clean:
cargo clean
rm -f /usr/local/bin/tblf

View File

@@ -1,4 +1,4 @@
# tbl
# tblf
A small binary that turns input like this:

View File

@@ -1,4 +1,4 @@
use std::env;
use std::{env,io};
fn main() {
// get args
@@ -14,7 +14,7 @@ fn main() {
let mut collect_str = String::new();
// try to get from stdin
while std::io::stdin().read_line(&mut input_str).unwrap() > 0 {
while io::stdin().read_line(&mut input_str).unwrap() > 0 {
collect_str.push_str(&input_str);
input_str.clear();
}
@@ -40,7 +40,12 @@ fn main() {
}
fn print_usage() {
println!("Usage:\n\ttbl <string> [separator]\n\tcat <file> | tbl [separator]");
println!("tblf ----- Format input as a table");
println!("");
println!("Usage:");
println!("");
println!(" tbl <string> [separator]");
println!(" <piped_output> | tbl [separator]");
}
fn format_as_table(input_str: &str, separator: &str, out_separator: &str) -> String {