Skip to content

Commit 177e34b

Browse files
committed
- [+] update usage doc
1 parent 718b911 commit 177e34b

4 files changed

Lines changed: 52 additions & 2 deletions

File tree

OpenSesame_cli.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ UsageSummary: ""
1313

1414
UsageLead: "\\nUsage:\\n %s [flags..]\\n\\nFlags:\\n\\n"
1515

16-
UsageEnd: "\\n"
16+
UsageEnd: "\\nWill serve the files from the given path via web server\\nof the given port using a one-time random path.\\n\\nExit and restart will serve from another random path.\\n\\nThe `-port` / `-path` can be overridden by environment variable(s)\\n `OPENSESAME_PORT` / `OPENSESAME_PATH`\\n"
1717

1818
Options:
1919

@@ -29,3 +29,8 @@ Options:
2929
Usage: path to serve files from
3030
Value: '"./"'
3131

32+
- Name: Help
33+
Type: bool
34+
Flag: help
35+
Usage: show usage help
36+
Value: false

OpenSesame_cliDef.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const progname = "OpenSesame" // os.Args[0]
1919
type Options struct {
2020
Port string // listening port
2121
Path string // path to serve files from
22+
Help bool // show usage help
2223
}
2324

2425
////////////////////////////////////////////////////////////////////////////
@@ -37,6 +38,8 @@ func init() {
3738
"listening port")
3839
flag.StringVar(&Opts.Path, "path", "./",
3940
"path to serve files from")
41+
flag.BoolVar(&Opts.Help, "help", false,
42+
"show usage help")
4043

4144
// Now override those default values from environment variables
4245
if len(Opts.Port) == 0 ||
@@ -57,6 +60,6 @@ func Usage() {
5760
progname)
5861
flag.PrintDefaults()
5962
fmt.Fprintf(os.Stderr,
60-
"\n")
63+
"\nWill serve the files from the given path via web server\nof the given port using a one-time random path.\n\nExit and restart will serve from another random path.\n\nThe `-port` / `-path` can be overridden by environment variable(s)\n `OPENSESAME_PORT` / `OPENSESAME_PATH`\n")
6164
os.Exit(0)
6265
}

OpenSesame_main.go

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

33
import (
4+
"flag"
45
"fmt"
56
"log"
67
"math/rand"
@@ -23,6 +24,10 @@ const MaxUint32 = int(^uint32(0))
2324

2425
// Function main
2526
func main() {
27+
flag.Parse()
28+
if Opts.Help {
29+
Usage()
30+
}
2631
rand.Seed(time.Now().UTC().UnixNano())
2732
app := fiber.New()
2833

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,39 @@
11
# OpenSesame
22
Open Sesame -- One-time based file sharing
3+
4+
## Usage
5+
6+
```sh
7+
8+
$ OpenSesame -h
9+
Usage of OpenSesame:
10+
-help
11+
show usage help
12+
-path string
13+
path to serve files from (default "./")
14+
-port string
15+
listening port (default ":18888")
16+
17+
$ OpenSesame -help
18+
19+
Usage:
20+
OpenSesame [flags..]
21+
22+
Flags:
23+
24+
-help
25+
show usage help
26+
-path string
27+
path to serve files from (default "./")
28+
-port string
29+
listening port (default ":18888")
30+
31+
Will serve the files from the given path via web server
32+
of the given port using a one-time random path.
33+
34+
Exit and restart will serve from another random path.
35+
36+
The `-port` / `-path` can be overridden by environment variable(s)
37+
`OPENSESAME_PORT` / `OPENSESAME_PATH`
38+
39+
```

0 commit comments

Comments
 (0)