Skip to content

Commit 84b6353

Browse files
committed
Working on getting READMEs up to snuff
1 parent ea161b6 commit 84b6353

6 files changed

Lines changed: 83 additions & 9 deletions

File tree

bin/build.sh

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,28 @@ if [ ! -d "${DIST_DIR}" ]; then
1919
mkdir "${REPO_DIR}/dist"
2020
fi
2121

22-
FILES=$(ls "${REPO_DIR}/cmd")
22+
CLEAN=1
23+
FILES=("$@")
24+
if [ ${#FILES[@]} -eq 0 ]; then
25+
echo "INFO: no files specified, building all files in ${REPO_DIR}/cmd"
26+
CLEAN=0
27+
FILES=($(ls "${REPO_DIR}/cmd"))
28+
fi
2329
LASTMOD=$(date -u +%Y-%m-%dT%H:%M:%SZ)
2430
COMMIT=$(git rev-parse --short HEAD)
2531
if [[ $(git diff --stat) != '' ]]; then
2632
COMMIT="${COMMIT}-dirty"
2733
fi
2834

29-
for f in $FILES; do
35+
for f in "${FILES[@]}"; do
3036
if [ -f "${DIST_DIR}/${f}" ]; then
31-
echo "WARNING: file ${DIST_DIR}/${f} already exists"
32-
continue
37+
if [ ${CLEAN} -eq 1 ]; then
38+
echo "INFO: removing existing file ${DIST_DIR}/${f}"
39+
rm "${DIST_DIR}/${f}"
40+
else
41+
echo "WARNING: file ${DIST_DIR}/${f} already exists"
42+
continue
43+
fi
3344
fi
3445
echo "INFO: compiling ${f} to dist directory"
3546
go build \

cmd/hosty/hosty.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package hosty
2+
3+
func main() {
4+
}

cmd/urly/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# urly
2+
3+
Get a URL into the specific form required by a program without regular expressions or custom parsers.
4+
5+
## Usage
6+
7+
The URL can be passed on the command line or in an environment value specified with `--url-env`.
8+
9+
The component (see table) can be set with the corresponding flag, or deleted with `-no-XXX` flag.
10+
11+
```
12+
┌─────────┬───┬──────────┬──────────┬─┬────────────────┬─┬──────┬──────────┬─┬──────────────┬─┬──────────┐
13+
│ scheme │ │ username │ password │ │ hostname │ │ port │ path │ │ query │ │ fragment │
14+
│ https :// user : pass @ sub.example.com : 8080 /p/a/t/h ? query=string # hash │
15+
└────────────────────────────────────────────────────────────────────────────────────────────────────────┘
16+
```
17+
18+
Password input is different: for security reasons, it should not be passed on the command line. You can pass
19+
it in via stdin with `--password-stdin` or set it via the environment with `--password-env`. Username can also
20+
be passed via the environment with `--username-env`.
21+
22+
Query string parameters are a little different: they can be set with `--setparam` or added with `--addparam` or
23+
deleted with `--delparam`.
24+
25+
The output can be the complete URL or a specific component with the `--output` flag. You can also output the
26+
complete parsed URL as formatted JSON with `--output=json` or a single line JSON with `--output=jsonl`.
27+
28+
## Exit Status
29+
30+
The program will exit with an errorlevel if it cannot parse the URL.
31+
32+
## Examples
33+
34+
Combine username and password from the environment to make a complete URL:
35+
```
36+
urly --username-env=DB_USER --password-env DB_PSWD "postgres://pgdbhost.example.com/db?sslMode=required"
37+
```
38+
39+
## Standards
40+
41+
[RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986): Uniform Resource Identifier (URI): Generic Syntax
42+
43+
## Security Considerations
44+
45+
While urly does not accept passwords on the command line, it will output URLs with a password if specified. Be careful with this output!

cmd/urly/urly.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
_ "embed"
45
"encoding/json"
56
"fmt"
67
"net/url"
@@ -17,6 +18,9 @@ var (
1718
VERSION = "internal"
1819
)
1920

21+
//go:embed README.md
22+
var helpText string
23+
2024
func setUserName(userInfo *url.Userinfo, username string) *url.Userinfo {
2125
if userInfo != nil {
2226
password, hasPassword := userInfo.Password()
@@ -101,9 +105,6 @@ func aliasFunc(f *pflag.FlagSet, name string) pflag.NormalizedName {
101105
return pflag.NormalizedName(name)
102106
}
103107

104-
// Detailed help text
105-
var helpText = `urly: A URL parsing and processing tool.`
106-
107108
func main() {
108109

109110
var scheme = pflag.String("scheme", "", "Set the URL scheme")
@@ -151,8 +152,7 @@ func main() {
151152
if *help {
152153
fmt.Println("urly - manipulate URLs")
153154
pflag.PrintDefaults()
154-
fmt.Println()
155-
fmt.Println("Use `man urly` for detailed help.")
155+
fmt.Printf("%s\n", helpText)
156156
return
157157
}
158158

cmd/wombat/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# wombat
2+
3+
Test your terminal endpoints with a quick ASCII animation

cmd/wombat/wombat.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ package main
22

33
import (
44
"fmt"
5+
"os"
56
"time"
67

78
. "github.com/FileFormatInfo/fftools/internal"
9+
"github.com/spf13/pflag"
810
)
911

1012
var (
@@ -16,6 +18,15 @@ var (
1618

1719
func main() {
1820

21+
var version = pflag.Bool("version", false, "Version info")
22+
23+
pflag.Parse()
24+
25+
if *version {
26+
fmt.Fprintf(os.Stdout, "wombat version %s (built by %s on %s, commit %s)\n", VERSION, BUILDER, LASTMOD, COMMIT)
27+
return
28+
}
29+
1930
oldState := Init()
2031
defer Deinit(oldState)
2132

0 commit comments

Comments
 (0)