Skip to content

Commit

Permalink
support stdin, clipboard, file and network cert at the same time
Browse files Browse the repository at this point in the history
  • Loading branch information
pete911 committed Jul 5, 2023
1 parent 46c2488 commit 20d365d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
7 changes: 1 addition & 6 deletions flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,5 @@ func getBoolEnv(envName string, defaultValue bool) bool {
}

func isClipboardSupported() bool {

if err := clipboard.Init(); err == nil {
return true
}

return false
return clipboard.Init() == nil
}
13 changes: 8 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ func main() {

func LoadCertificatesLocations(flags Flags) cert.CertificateLocations {

var certificateLocations cert.CertificateLocations
if flags.Clipboard {
certificateLocation, err := cert.LoadCertificateFromClipboard()
if err != nil {
printCertFileError("clipboard", err)
return nil
}
return []cert.CertificateLocation{certificateLocation}
certificateLocations = append(certificateLocations, certificateLocation)
}

if len(flags.Args) > 0 {
var certificateLocations cert.CertificateLocations
for _, arg := range flags.Args {

var certificateLocation cert.CertificateLocation
Expand All @@ -70,7 +70,6 @@ func LoadCertificatesLocations(flags Flags) cert.CertificateLocations {
}
certificateLocations = append(certificateLocations, certificateLocation)
}
return certificateLocations
}

if isStdin() {
Expand All @@ -79,10 +78,14 @@ func LoadCertificatesLocations(flags Flags) cert.CertificateLocations {
printCertFileError("stdin", err)
return nil
}
return []cert.CertificateLocation{certificateLocation}
certificateLocations = append(certificateLocations, certificateLocation)
}

if len(certificateLocations) > 0 {
return certificateLocations
}

// no stdin and not args
// no stdin and no args
flags.Usage()
os.Exit(0)
return nil
Expand Down
18 changes: 9 additions & 9 deletions vendor/golang.org/x/mobile/gl/work_windows_386.s

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 20d365d

Please sign in to comment.