init
This commit is contained in:
commit
6c9dcb95e9
3 changed files with 53 additions and 0 deletions
0
.gitignore
vendored
Normal file
0
.gitignore
vendored
Normal file
50
fatten.go
Normal file
50
fatten.go
Normal file
|
@ -0,0 +1,50 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var fat_table []string = []string{
|
||||
"<",
|
||||
">",
|
||||
":",
|
||||
"\"",
|
||||
"/",
|
||||
"\\",
|
||||
"|",
|
||||
"?",
|
||||
"*",
|
||||
}
|
||||
|
||||
func fatten(stdin bool, data string) {
|
||||
for _, i := range fat_table {
|
||||
data = strings.ReplaceAll(data, i, "_")
|
||||
}
|
||||
if stdin {
|
||||
fmt.Print(data)
|
||||
} else {
|
||||
fmt.Println(data)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
if len(flag.Args()) > 0 {
|
||||
for _, i := range flag.Args() {
|
||||
fatten(false, i)
|
||||
}
|
||||
} else {
|
||||
stdin, err := io.ReadAll(os.Stdin)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fatten(true, string(stdin))
|
||||
}
|
||||
|
||||
os.Exit(0)
|
||||
}
|
3
go.mod
Normal file
3
go.mod
Normal file
|
@ -0,0 +1,3 @@
|
|||
module brysonsteck.xyz/fatten
|
||||
|
||||
go 1.24.3
|
Loading…
Add table
Reference in a new issue