forked from TrueCloudLab/certificates
parent
8a05cdde52
commit
6592c4784b
1 changed files with 44 additions and 34 deletions
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
@ -143,6 +144,25 @@ intermediate private key.`,
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Action = func(ctx *cli.Context) error {
|
app.Action = func(ctx *cli.Context) error {
|
||||||
|
// Hack to be able to run a the top action as a subcommand
|
||||||
|
cmd := cli.Command{Name: "start", Action: startAction, Flags: app.Flags}
|
||||||
|
set := flag.NewFlagSet(app.Name, flag.ContinueOnError)
|
||||||
|
set.Parse(os.Args)
|
||||||
|
ctx = cli.NewContext(app, set, nil)
|
||||||
|
return cmd.Run(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := app.Run(os.Args); err != nil {
|
||||||
|
if os.Getenv("STEPDEBUG") == "1" {
|
||||||
|
fmt.Fprintf(os.Stderr, "%+v\n", err)
|
||||||
|
} else {
|
||||||
|
fmt.Fprintln(os.Stderr, err)
|
||||||
|
}
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func startAction(ctx *cli.Context) error {
|
||||||
passFile := ctx.String("password-file")
|
passFile := ctx.String("password-file")
|
||||||
|
|
||||||
// If zero cmd line args show help, if >1 cmd line args show error.
|
// If zero cmd line args show help, if >1 cmd line args show error.
|
||||||
|
@ -179,16 +199,6 @@ intermediate private key.`,
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.Run(os.Args); err != nil {
|
|
||||||
if os.Getenv("STEPDEBUG") == "1" {
|
|
||||||
fmt.Fprintf(os.Stderr, "%+v\n", err)
|
|
||||||
} else {
|
|
||||||
fmt.Fprintln(os.Stderr, err)
|
|
||||||
}
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// fatal writes the passed error on the standard error and exits with the exit
|
// fatal writes the passed error on the standard error and exits with the exit
|
||||||
// code 1. If the environment variable STEPDEBUG is set to 1 it shows the
|
// code 1. If the environment variable STEPDEBUG is set to 1 it shows the
|
||||||
// stack trace of the error.
|
// stack trace of the error.
|
||||||
|
|
Loading…
Reference in a new issue