Skip to content

Commit

Permalink
fix(backend/mintter-site): fix CLI flags handling
Browse files Browse the repository at this point in the history
  • Loading branch information
burdiyan committed Sep 21, 2023
1 parent acdf6fd commit bff21db
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions backend/cmd/mintter-site/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func main() {

fs := flag.NewFlagSet("mintter-site", flag.ExitOnError)
fs.Usage = func() {
fmt.Fprintf(fs.Output(), `Usage: %s ADDRESS [flags]
fmt.Fprintf(fs.Output(), `Usage: %s [flags] ADDRESS
This program is similar to our main mintterd program in a lot of ways, but has more suitable defaults for running on a server as site.
Expand All @@ -41,17 +41,19 @@ Flags:

cfg := sites.DefaultConfig()
cfg.BindFlags(fs)
if err := ff.Parse(fs, os.Args[2:], ff.WithEnvVarPrefix(envVarPrefix)); err != nil {
if err := ff.Parse(fs, os.Args[1:], ff.WithEnvVarPrefix(envVarPrefix)); err != nil {
return err
}

if len(os.Args) < 2 {
args := fs.Args()

if len(args) != 1 {
fs.Usage()
fmt.Fprintf(fs.Output(), "Error: Positional argument ADDRESS is missing.\n")
fmt.Fprintf(fs.Output(), "Error: Positional argument ADDRESS is required.\n")
os.Exit(1)
}

rawURL := os.Args[1]
rawURL := args[0]

if err := cfg.Base.ExpandDataDir(); err != nil {
return err
Expand Down

0 comments on commit bff21db

Please sign in to comment.