Skip to content

Commit c2b6818

Browse files
authored
Add Option to Exit Program & Update Documentation (#1)
* Feat Option to Exit Program - [+] feat: add option to exit program at each input prompt - [+] The program now allows the user to type 'exit' at each input prompt to quit the program gracefully. * Docs [README] Update Documentation - [+] docs(README.md): remove duplicate csr from pkg.go.dev URL
1 parent 29ac82f commit c2b6818

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# CSR Generator
22

3-
[![Go Reference](https://pkg.go.dev/badge/github.com/H0llyW00dzZ/csr-generator/csr.svg)](https://pkg.go.dev/github.com/H0llyW00dzZ/csr-generator/csr)
3+
[![Go Reference](https://pkg.go.dev/badge/github.com/H0llyW00dzZ/csr-generator/csr.svg)](https://pkg.go.dev/github.com/H0llyW00dzZ/csr-generator)
44

55
The CSR Generator is a Go package that provides functionality for generating Certificate Signing Requests (CSRs) and private keys. It simplifies the process of creating CSRs with specified common names and Subject Alternative Names (SANs).
66

run.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,40 @@ import (
1818
func main() {
1919
reader := bufio.NewReader(os.Stdin)
2020

21-
fmt.Print("Enter the common name (domain name): ")
21+
fmt.Print("Enter the common name (domain name) or type 'exit' to quit: ")
2222
commonName, _ := reader.ReadString('\n')
2323
commonName = strings.TrimSpace(commonName)
2424

25-
fmt.Print("Enter the number of Subject Alternative Names (SANs): ")
25+
if commonName == "exit" {
26+
fmt.Println("Exiting the program.")
27+
return
28+
}
29+
30+
fmt.Print("Enter the number of Subject Alternative Names (SANs) or type 'exit' to quit: ")
2631
sanCountStr, _ := reader.ReadString('\n')
2732
sanCountStr = strings.TrimSpace(sanCountStr)
33+
34+
if sanCountStr == "exit" {
35+
fmt.Println("Exiting the program.")
36+
return
37+
}
38+
2839
sanCount, err := strconv.Atoi(sanCountStr)
2940
if err != nil {
3041
log.Fatalf("Invalid number of SANs: %v", err)
3142
}
3243

3344
var dnsNames []string
3445
for i := 0; i < sanCount; i++ {
35-
fmt.Printf("Enter SAN %d (DNS name): ", i+1)
46+
fmt.Printf("Enter SAN %d (DNS name) or type 'exit' to quit: ", i+1)
3647
dnsName, _ := reader.ReadString('\n')
3748
dnsName = strings.TrimSpace(dnsName)
49+
50+
if dnsName == "exit" {
51+
fmt.Println("Exiting the program.")
52+
return
53+
}
54+
3855
dnsNames = append(dnsNames, dnsName)
3956
}
4057

0 commit comments

Comments
 (0)