forked from TrueCloudLab/lego
Adds --name flag to list command. (#1046)
This commit is contained in:
parent
68842b3b70
commit
aeb20f4deb
1 changed files with 23 additions and 8 deletions
|
@ -22,12 +22,16 @@ func createList() cli.Command {
|
||||||
Name: "accounts, a",
|
Name: "accounts, a",
|
||||||
Usage: "Display accounts.",
|
Usage: "Display accounts.",
|
||||||
},
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "names, n",
|
||||||
|
Usage: "Display certificate common names only.",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func list(ctx *cli.Context) error {
|
func list(ctx *cli.Context) error {
|
||||||
if ctx.Bool("accounts") {
|
if ctx.Bool("accounts") && !ctx.Bool("names") {
|
||||||
if err := listAccount(ctx); err != nil {
|
if err := listAccount(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -44,12 +48,19 @@ func listCertificates(ctx *cli.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
names := ctx.Bool("names")
|
||||||
|
|
||||||
if len(matches) == 0 {
|
if len(matches) == 0 {
|
||||||
|
if !names {
|
||||||
fmt.Println("No certificates found.")
|
fmt.Println("No certificates found.")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !names {
|
||||||
fmt.Println("Found the following certs:")
|
fmt.Println("Found the following certs:")
|
||||||
|
}
|
||||||
|
|
||||||
for _, filename := range matches {
|
for _, filename := range matches {
|
||||||
if strings.HasSuffix(filename, ".issuer.crt") {
|
if strings.HasSuffix(filename, ".issuer.crt") {
|
||||||
continue
|
continue
|
||||||
|
@ -65,12 +76,16 @@ func listCertificates(ctx *cli.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if names {
|
||||||
|
fmt.Println(pCert.Subject.CommonName)
|
||||||
|
} else {
|
||||||
fmt.Println(" Certificate Name:", pCert.Subject.CommonName)
|
fmt.Println(" Certificate Name:", pCert.Subject.CommonName)
|
||||||
fmt.Println(" Domains:", strings.Join(pCert.DNSNames, ", "))
|
fmt.Println(" Domains:", strings.Join(pCert.DNSNames, ", "))
|
||||||
fmt.Println(" Expiry Date:", pCert.NotAfter)
|
fmt.Println(" Expiry Date:", pCert.NotAfter)
|
||||||
fmt.Println(" Certificate Path:", filename)
|
fmt.Println(" Certificate Path:", filename)
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue