add readme

This commit is contained in:
2026-03-30 21:51:48 +01:00
parent a98ef28055
commit 31d0e05dfd
4 changed files with 24 additions and 8 deletions
+19
View File
@@ -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.
+2 -2
View File
@@ -2,6 +2,6 @@ package internal
type CLI struct { type CLI struct {
File string `arg:"" name:"file" short:"f" help:"Path to CSV redirects file." type:"path"` 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}"` Host string `name:"host" help:"HTTP listen host." default:"localhost"`
Port string `name:"port" short:"p" help:"HTTP listen port." default:"${port}"` Port string `name:"port" short:"p" help:"HTTP listen port." default:"4000"`
} }
+2
View File
@@ -41,7 +41,9 @@ func ReadCsvRedirects(file string) (Redirects, error) {
return nil, errors.New("CSV must contain From, To, and Status Code headings") return nil, errors.New("CSV must contain From, To, and Status Code headings")
} }
// Read data
redirects := Redirects{} redirects := Redirects{}
for { for {
row, err := csvReader.Read() row, err := csvReader.Read()
if err != nil { if err != nil {
+1 -6
View File
@@ -10,13 +10,8 @@ import (
) )
func main() { func main() {
vars := kong.Vars{
"host": "localhost",
"port": "4000",
}
cli := &internal.CLI{} 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) redirects, err := internal.ReadCsvRedirects(cli.File)
if err != nil { if err != nil {