From 31d0e05dfd7d4a4a3c2dd7a2ac2e01c13902f3d7 Mon Sep 17 00:00:00 2001 From: Aneurin Barker Snook Date: Mon, 30 Mar 2026 21:51:48 +0100 Subject: [PATCH] add readme --- README.md | 19 +++++++++++++++++++ internal/cli.go | 4 ++-- internal/csv.go | 2 ++ main.go | 7 +------ 4 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..b9db8a4 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# Ultrashorty + +Really simple HTTP redirection using a CSV file. + +## Usage + +Create a CSV file with the following headings and add in as many redirects as you like: + +```csv +From,To,Status Code +``` + +Start Ultrashorty: + +```sh +ultrashorty /path/to/redirects.csv +``` + +To load changes to the CSV, just stop and restart Ultrashorty. diff --git a/internal/cli.go b/internal/cli.go index 6045b6a..e56bb96 100644 --- a/internal/cli.go +++ b/internal/cli.go @@ -2,6 +2,6 @@ package internal type CLI struct { File string `arg:"" name:"file" short:"f" help:"Path to CSV redirects file." type:"path"` - Host string `name:"host" help:"HTTP listen host." default:"${host}"` - Port string `name:"port" short:"p" help:"HTTP listen port." default:"${port}"` + Host string `name:"host" help:"HTTP listen host." default:"localhost"` + Port string `name:"port" short:"p" help:"HTTP listen port." default:"4000"` } diff --git a/internal/csv.go b/internal/csv.go index d22ea45..d2b5877 100644 --- a/internal/csv.go +++ b/internal/csv.go @@ -41,7 +41,9 @@ func ReadCsvRedirects(file string) (Redirects, error) { return nil, errors.New("CSV must contain From, To, and Status Code headings") } + // Read data redirects := Redirects{} + for { row, err := csvReader.Read() if err != nil { diff --git a/main.go b/main.go index 09e4b1f..88aae22 100644 --- a/main.go +++ b/main.go @@ -10,13 +10,8 @@ import ( ) func main() { - vars := kong.Vars{ - "host": "localhost", - "port": "4000", - } - cli := &internal.CLI{} - kong.Parse(cli, vars) + kong.Parse(cli, kong.Name("ultrashorty"), kong.Description("Really simple HTTP redirection using a CSV file.")) redirects, err := internal.ReadCsvRedirects(cli.File) if err != nil {