Skip to content

Commit acacf23

Browse files
committed
install NDEF by default with empty data
1 parent 14a2034 commit acacf23

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

VERSION

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

installer.go

Lines changed: 12 additions & 5 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, installKeycard bool, installCash bool, ndefRecordTemplate string) error {
35+
func (i *Installer) Install(capFile *os.File, overwriteApplet bool, installKeycard bool, installCash bool, installNDEF bool, ndefRecordTemplate string) error {
3636
logger.Info("installation started")
3737
startTime := time.Now()
3838
cmdSet := globalplatform.NewCommandSet(i.c)
@@ -87,10 +87,17 @@ func (i *Installer) Install(capFile *os.File, overwriteApplet bool, installKeyca
8787
}
8888
}
8989

90-
if ndefRecordTemplate != "" {
91-
ndefURL, ndefRecord, err := i.buildNDEFRecordWithCashAppletData(ndefRecordTemplate)
92-
if err != nil {
93-
return err
90+
if installNDEF {
91+
var (
92+
ndefURL string
93+
ndefRecord []byte
94+
)
95+
96+
if ndefRecordTemplate != "" {
97+
ndefURL, ndefRecord, err = i.buildNDEFRecordWithCashAppletData(ndefRecordTemplate)
98+
if err != nil {
99+
return err
100+
}
94101
}
95102

96103
logger.Info("setting NDEF url", "url", ndefURL)

main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ var (
2929
flagCapFile = flag.String("a", "", "applet cap file path")
3030
flagKeycardApplet = flag.Bool("keycard-applet", true, "install keycard applet")
3131
flagCashApplet = flag.Bool("cash-applet", true, "install cash applet")
32+
flagNDEFApplet = flag.Bool("ndef-applet", true, "install NDEF applet")
3233
flagOverwrite = flag.Bool("f", false, "force applet installation if already installed")
3334
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}}.")
35+
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}}.")
3536
)
3637

3738
func initLogger() {
@@ -238,7 +239,7 @@ func commandInstall(card *scard.Card) error {
238239
defer f.Close()
239240

240241
i := NewInstaller(card)
241-
return i.Install(f, *flagOverwrite, *flagKeycardApplet, *flagCashApplet, *flagNdefTemplate)
242+
return i.Install(f, *flagOverwrite, *flagKeycardApplet, *flagCashApplet, *flagNDEFApplet, *flagNDEFTemplate)
242243
}
243244

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

0 commit comments

Comments
 (0)