Skip to content

Commit 14a2034

Browse files
committed
add -keycard-applet and -cash-applet flags
1 parent 7979faf commit 14a2034

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.4.0
1+
0.5.0

installer.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func NewInstaller(t keycardio.Transmitter) *Installer {
3232
}
3333

3434
// Install installs the applet from the specified capFile.
35-
func (i *Installer) Install(capFile *os.File, overwriteApplet bool, ndefRecordTemplate string) error {
35+
func (i *Installer) Install(capFile *os.File, overwriteApplet bool, installKeycard bool, installCash bool, ndefRecordTemplate string) error {
3636
logger.Info("installation started")
3737
startTime := time.Now()
3838
cmdSet := globalplatform.NewCommandSet(i.c)
@@ -71,16 +71,20 @@ func (i *Installer) Install(capFile *os.File, overwriteApplet bool, ndefRecordTe
7171
return err
7272
}
7373

74-
logger.Info("installing Keycard applet")
75-
if err = cmdSet.InstallKeycardApplet(); err != nil {
76-
logger.Error("installing Keycard applet failed", "error", err)
77-
return err
74+
if installKeycard {
75+
logger.Info("installing Keycard applet")
76+
if err = cmdSet.InstallKeycardApplet(); err != nil {
77+
logger.Error("installing Keycard applet failed", "error", err)
78+
return err
79+
}
7880
}
7981

80-
logger.Info("installing Cash applet")
81-
if err = cmdSet.InstallCashApplet(); err != nil {
82-
logger.Error("installing Cash applet failed", "error", err)
83-
return err
82+
if installCash {
83+
logger.Info("installing Cash applet")
84+
if err = cmdSet.InstallCashApplet(); err != nil {
85+
logger.Error("installing Cash applet failed", "error", err)
86+
return err
87+
}
8488
}
8589

8690
if ndefRecordTemplate != "" {

main.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ var (
2626
commands map[string]commandFunc
2727
command string
2828

29-
flagCapFile = flag.String("a", "", "applet cap file path")
30-
flagOverwrite = flag.Bool("f", false, "force applet installation if already installed")
31-
flagLogLevel = flag.String("l", "", `Log level, one of: "error", "warn", "info", "debug", and "trace"`)
32-
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}}.")
29+
flagCapFile = flag.String("a", "", "applet cap file path")
30+
flagKeycardApplet = flag.Bool("keycard-applet", true, "install keycard applet")
31+
flagCashApplet = flag.Bool("cash-applet", true, "install cash applet")
32+
flagOverwrite = flag.Bool("f", false, "force applet installation if already installed")
33+
flagLogLevel = flag.String("l", "", `Log level, one of: "error", "warn", "info", "debug", and "trace"`)
34+
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}}.")
3335
)
3436

3537
func initLogger() {
@@ -236,8 +238,7 @@ func commandInstall(card *scard.Card) error {
236238
defer f.Close()
237239

238240
i := NewInstaller(card)
239-
240-
return i.Install(f, *flagOverwrite, *flagNdefTemplate)
241+
return i.Install(f, *flagOverwrite, *flagKeycardApplet, *flagCashApplet, *flagNdefTemplate)
241242
}
242243

243244
func commandInfo(card *scard.Card) error {

0 commit comments

Comments
 (0)