Skip to content

Commit 83ca8ec

Browse files
authored
goal abi method outfile checking (#3204)
Check if the outFilename argument is passed and write to the path specified as other commands
1 parent 38329e1 commit 83ca8ec

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

cmd/goal/application.go

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,10 @@ func init() {
176176

177177
infoAppCmd.MarkFlagRequired("app-id")
178178

179-
methodAppCmd.MarkFlagRequired("method") // nolint:errcheck // follow previous required flag format
180-
methodAppCmd.MarkFlagRequired("app-id") // nolint:errcheck
181-
methodAppCmd.MarkFlagRequired("from") // nolint:errcheck
182-
methodAppCmd.Flags().MarkHidden("app-arg") // nolint:errcheck
183-
methodAppCmd.Flags().MarkHidden("app-input") // nolint:errcheck
184-
methodAppCmd.Flags().MarkHidden("i") // nolint:errcheck
179+
methodAppCmd.MarkFlagRequired("method") // nolint:errcheck // follow previous required flag format
180+
methodAppCmd.MarkFlagRequired("app-id") // nolint:errcheck
181+
methodAppCmd.MarkFlagRequired("from") // nolint:errcheck
182+
methodAppCmd.Flags().MarkHidden("app-arg") // nolint:errcheck
185183
}
186184

187185
type appCallArg struct {
@@ -1116,6 +1114,20 @@ var methodAppCmd = &cobra.Command{
11161114
tx.Fee = basics.MicroAlgos{Raw: fee}
11171115
}
11181116

1117+
if outFilename != "" {
1118+
if dumpForDryrun {
1119+
err = writeDryrunReqToFile(client, tx, outFilename)
1120+
} else {
1121+
// Write transaction to file
1122+
err = writeTxnToFile(client, sign, dataDir, walletName, tx, outFilename)
1123+
}
1124+
1125+
if err != nil {
1126+
reportErrorf(err.Error())
1127+
}
1128+
return
1129+
}
1130+
11191131
// Broadcast
11201132
wh, pw := ensureWalletHandleMaybePassword(dataDir, walletName, true)
11211133
signedTxn, err := client.SignTransactionWithWallet(wh, pw, tx)
@@ -1180,7 +1192,7 @@ var methodAppCmd = &cobra.Command{
11801192
if err != nil {
11811193
reportErrorf("cannot marshal returned bytes %v to JSON: %v", decoded, err)
11821194
}
1183-
fmt.Printf("method %s output: %s", method, string(decodedJSON))
1195+
fmt.Printf("method %s output: %s\n", method, string(decodedJSON))
11841196
}
11851197
},
11861198
}

0 commit comments

Comments
 (0)