mirror of
https://github.com/luxfi/cli.git
synced 2026-10-30 17:01:20 +00:00
120 lines
2.0 KiB
Go
120 lines
2.0 KiB
Go
// Copyright (C) 2022, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
package commands
|
|
|
|
import (
|
|
"os/exec"
|
|
|
|
"github.com/luxfi/cli/v2/pkg/constants"
|
|
)
|
|
|
|
/* #nosec G204 */
|
|
func CreateKey(keyName string) (string, error) {
|
|
// Create config
|
|
cmd := exec.Command(
|
|
CLIBinary,
|
|
KeyCmd,
|
|
"create",
|
|
keyName,
|
|
"--"+constants.SkipUpdateFlag,
|
|
)
|
|
|
|
out, err := cmd.Output()
|
|
return string(out), err
|
|
}
|
|
|
|
/* #nosec G204 */
|
|
func CreateKeyFromPath(keyName string, keyPath string) (string, error) {
|
|
// Create config
|
|
cmd := exec.Command(
|
|
CLIBinary,
|
|
KeyCmd,
|
|
"create",
|
|
"--file",
|
|
keyPath,
|
|
keyName,
|
|
"--"+constants.SkipUpdateFlag,
|
|
)
|
|
out, err := cmd.Output()
|
|
return string(out), err
|
|
}
|
|
|
|
/* #nosec G204 */
|
|
func CreateKeyForce(keyName string) (string, error) {
|
|
// Create config
|
|
cmd := exec.Command(
|
|
CLIBinary,
|
|
KeyCmd,
|
|
"create",
|
|
keyName,
|
|
"--force",
|
|
"--"+constants.SkipUpdateFlag,
|
|
)
|
|
|
|
out, err := cmd.Output()
|
|
return string(out), err
|
|
}
|
|
|
|
/* #nosec G204 */
|
|
func ListKeys() (string, error) {
|
|
// Create config
|
|
cmd := exec.Command(
|
|
CLIBinary,
|
|
KeyCmd,
|
|
"list",
|
|
"--mainnet",
|
|
"--"+constants.SkipUpdateFlag,
|
|
)
|
|
|
|
out, err := cmd.Output()
|
|
return string(out), err
|
|
}
|
|
|
|
/* #nosec G204 */
|
|
func DeleteKey(keyName string) (string, error) {
|
|
// Create config
|
|
cmd := exec.Command(
|
|
CLIBinary,
|
|
KeyCmd,
|
|
"delete",
|
|
keyName,
|
|
"--force",
|
|
"--"+constants.SkipUpdateFlag,
|
|
)
|
|
|
|
out, err := cmd.Output()
|
|
return string(out), err
|
|
}
|
|
|
|
/* #nosec G204 */
|
|
func ExportKey(keyName string) (string, error) {
|
|
// Create config
|
|
cmd := exec.Command(
|
|
CLIBinary,
|
|
KeyCmd,
|
|
"export",
|
|
keyName,
|
|
"--"+constants.SkipUpdateFlag,
|
|
)
|
|
|
|
out, err := cmd.Output()
|
|
return string(out), err
|
|
}
|
|
|
|
/* #nosec G204 */
|
|
func ExportKeyToFile(keyName string, outputPath string) (string, error) {
|
|
// Create config
|
|
cmd := exec.Command(
|
|
CLIBinary,
|
|
KeyCmd,
|
|
"export",
|
|
keyName,
|
|
"-o",
|
|
outputPath,
|
|
"--"+constants.SkipUpdateFlag,
|
|
)
|
|
|
|
out, err := cmd.Output()
|
|
return string(out), err
|
|
}
|