-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
50 lines (43 loc) · 1.52 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
package main
import (
"github.com/archethic-foundation/archethic-cli/cli"
"github.com/archethic-foundation/archethic-cli/tui"
"github.com/archethic-foundation/archethic-cli/tui/tuiutils"
"github.com/spf13/cobra"
)
var rootCmd = &cobra.Command{
Use: "archethic-cli",
Short: "Archethic CLI",
Run: func(cmd *cobra.Command, args []string) {
var privateKey []byte
ssh, _ := cmd.Flags().GetBool("ssh")
isSshPathSet := cmd.Flag("ssh-path").Changed
isSshEnabled := ssh || isSshPathSet
if isSshEnabled {
var err error
privateKey, err = tuiutils.GetSeedBytes(cmd.Flags(), "ssh", "ssh-path", "", "")
cobra.CheckErr(err)
}
tui.StartTea(privateKey)
},
}
func main() {
generateAddressCmd := cli.GetGenerateAddressCmd()
sendTransactionCmd := cli.GetSendTransactionCmd()
getTransactionFeeCmd := cli.GetGetTransactionFeeCmd()
createKeychainCmd := cli.GetCreateKeychainCmd()
getKeychainCmd := cli.GetKeychainCmd()
addServiceToKeychainCmd := cli.GetAddServiceToKeychainCmd()
deleteServiceFromKeychainCmd := cli.GetDeleteServiceFromKeychainCmd()
rootCmd.AddCommand(generateAddressCmd)
rootCmd.AddCommand(sendTransactionCmd)
rootCmd.AddCommand(getTransactionFeeCmd)
rootCmd.AddCommand(createKeychainCmd)
rootCmd.AddCommand(getKeychainCmd)
rootCmd.AddCommand(addServiceToKeychainCmd)
rootCmd.AddCommand(deleteServiceFromKeychainCmd)
rootCmd.Flags().Bool("ssh", false, "Enable SSH key mode")
rootCmd.Flags().String("ssh-path", cli.GetFirstSshKeyDefaultPath(), "Path to ssh key")
err := rootCmd.Execute()
cobra.CheckErr(err)
}