-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (36 loc) · 1.04 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
package main
import (
"fmt"
"log"
"os"
"time"
"github.com/corenting/cookies/internal/decryption"
"github.com/corenting/cookies/internal/entities"
"github.com/urfave/cli/v2"
)
func main() {
app := &cli.App{
Name: "cookies",
Usage: "decrypt cookies content",
Action: decryptCommand,
Version: entities.AppVersion,
Compiled: time.Now(),
UsageText: "cookies [global options] cookie_to_decrypt",
HideHelpCommand: true,
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}
// The main command is the decrypt command tries to identify the cookie provided, decrypt it and print the result to the user.
func decryptCommand(context *cli.Context) error {
if context.Args().Len() != 1 {
return cli.Exit("You need to provide a cookie to decrypt.", 1)
}
decryptedCookie, err := decryption.DecryptCookie(context.Args().First())
if err != nil {
return cli.Exit("Error decoding the provided cookie, maybe it's not supported?", 1)
}
fmt.Println(decryptedCookie)
return nil
}