This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
58 lines (48 loc) · 1.54 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
"github.com/c-bata/go-prompt"
"github.com/gookit/color"
"ncrypt-cli/helpers"
"ncrypt-cli/models"
"ncrypt-cli/services"
"net/http"
"os"
)
func main() {
c := buildSuggestions()
color.FgLightBlue.Println("nCrypt.site CLI V1.0.0\n")
color.Green.Print("enter your note:")
color.Cyan.Println(" (we will secure it for you)")
note := prompt.Input("> ", c.noSuggestion)
color.Green.Println("how long should we retain the note?")
selfDestructInput := prompt.Input("> ", c.selfDestructSuggestions)
selfDestruct, err := helpers.ConvertSelfDestructToInt(selfDestructInput)
if err != nil {
color.Red.Println(err)
os.Exit(2)
}
color.Green.Println("should we destroy the secure note once it's opened?")
destructAfterOpeningInput := prompt.Input("> ", c.destructAfterOpeningSuggestions)
destructAfterOpening, err := helpers.ConvertDestructAfterOpeningToBool(destructAfterOpeningInput)
if err != nil {
color.Red.Println(err)
os.Exit(2)
}
h := services.HttpService{
Client: &http.Client{},
Url: "https://api.ncrypt.site/api/v1/note",
}
r, key, err := services.CreateNote(h, models.Note{
Note: []byte(note),
SelfDestruct: selfDestruct,
DestructAfterOpening: destructAfterOpening,
})
if err != nil {
color.Red.Println(err)
os.Exit(2)
}
color.Green.Println("Note has been created, the following url is now holds your secure note:")
color.FgLightRed.Println(r.URL)
color.Green.Println("Whoever receives the note will need the following key to open it:")
color.FgLightRed.Println(key)
}