mirror of
https://github.com/status-im/keycard-cli.git
synced 2025-02-28 11:50:43 +00:00
add -keycard-applet and -cash-applet flags
This commit is contained in:
parent
7979faf8de
commit
14a203452b
22
installer.go
22
installer.go
@ -32,7 +32,7 @@ func NewInstaller(t keycardio.Transmitter) *Installer {
|
||||
}
|
||||
|
||||
// Install installs the applet from the specified capFile.
|
||||
func (i *Installer) Install(capFile *os.File, overwriteApplet bool, ndefRecordTemplate string) error {
|
||||
func (i *Installer) Install(capFile *os.File, overwriteApplet bool, installKeycard bool, installCash bool, ndefRecordTemplate string) error {
|
||||
logger.Info("installation started")
|
||||
startTime := time.Now()
|
||||
cmdSet := globalplatform.NewCommandSet(i.c)
|
||||
@ -71,16 +71,20 @@ func (i *Installer) Install(capFile *os.File, overwriteApplet bool, ndefRecordTe
|
||||
return err
|
||||
}
|
||||
|
||||
logger.Info("installing Keycard applet")
|
||||
if err = cmdSet.InstallKeycardApplet(); err != nil {
|
||||
logger.Error("installing Keycard applet failed", "error", err)
|
||||
return err
|
||||
if installKeycard {
|
||||
logger.Info("installing Keycard applet")
|
||||
if err = cmdSet.InstallKeycardApplet(); err != nil {
|
||||
logger.Error("installing Keycard applet failed", "error", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
logger.Info("installing Cash applet")
|
||||
if err = cmdSet.InstallCashApplet(); err != nil {
|
||||
logger.Error("installing Cash applet failed", "error", err)
|
||||
return err
|
||||
if installCash {
|
||||
logger.Info("installing Cash applet")
|
||||
if err = cmdSet.InstallCashApplet(); err != nil {
|
||||
logger.Error("installing Cash applet failed", "error", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if ndefRecordTemplate != "" {
|
||||
|
13
main.go
13
main.go
@ -26,10 +26,12 @@ var (
|
||||
commands map[string]commandFunc
|
||||
command string
|
||||
|
||||
flagCapFile = flag.String("a", "", "applet cap file path")
|
||||
flagOverwrite = flag.Bool("f", false, "force applet installation if already installed")
|
||||
flagLogLevel = flag.String("l", "", `Log level, one of: "error", "warn", "info", "debug", and "trace"`)
|
||||
flagNdefTemplate = flag.String("ndef", "", "Specify a URL to use in the NDEF record. Use the {{.cashAddress}} variable to get the cash address: http://example.com/{{.cashAddress}}.")
|
||||
flagCapFile = flag.String("a", "", "applet cap file path")
|
||||
flagKeycardApplet = flag.Bool("keycard-applet", true, "install keycard applet")
|
||||
flagCashApplet = flag.Bool("cash-applet", true, "install cash applet")
|
||||
flagOverwrite = flag.Bool("f", false, "force applet installation if already installed")
|
||||
flagLogLevel = flag.String("l", "", `Log level, one of: "error", "warn", "info", "debug", and "trace"`)
|
||||
flagNdefTemplate = flag.String("ndef", "", "Specify a URL to use in the NDEF record. Use the {{.cashAddress}} variable to get the cash address: http://example.com/{{.cashAddress}}.")
|
||||
)
|
||||
|
||||
func initLogger() {
|
||||
@ -236,8 +238,7 @@ func commandInstall(card *scard.Card) error {
|
||||
defer f.Close()
|
||||
|
||||
i := NewInstaller(card)
|
||||
|
||||
return i.Install(f, *flagOverwrite, *flagNdefTemplate)
|
||||
return i.Install(f, *flagOverwrite, *flagKeycardApplet, *flagCashApplet, *flagNdefTemplate)
|
||||
}
|
||||
|
||||
func commandInfo(card *scard.Card) error {
|
||||
|
Loading…
x
Reference in New Issue
Block a user