66 "time"
77
88 "github.com/spf13/cobra"
9- flag "github.com/spf13/pflag"
109
1110 "github.com/oasisprotocol/oasis-core/go/common/cbor"
1211 "github.com/oasisprotocol/oasis-sdk/client-sdk/go/client"
@@ -22,9 +21,6 @@ import (
2221)
2322
2423var (
25- topUpTerm string
26- topUpTermCount uint64
27-
2824 showCmd = & cobra.Command {
2925 Use : "show [<machine-name>]" ,
3026 Short : "Show information about a machine" ,
@@ -262,13 +258,16 @@ var (
262258 // Resolve provider address.
263259 providerAddr , _ , err := common .ResolveLocalAccountOrAddress (npa .Network , machine .Provider )
264260 if err != nil {
265- cobra .CheckErr (fmt .Sprintf ("Invalid provider address: %s" , err ))
261+ cobra .CheckErr (fmt .Sprintf ("invalid provider address: %s" , err ))
266262 }
267263
268264 // Parse machine payment term.
269- term := roflCommon .ParseMachineTerm (topUpTerm )
270- if topUpTermCount < 1 {
271- cobra .CheckErr ("Number of terms must be at least 1." )
265+ if roflCommon .Term == "" {
266+ cobra .CheckErr ("no term period specified. Use --term to specify it" )
267+ }
268+ term := roflCommon .ParseMachineTerm (roflCommon .Term )
269+ if roflCommon .TermCount < 1 {
270+ cobra .CheckErr ("number of terms must be at least 1." )
272271 }
273272
274273 // When not in offline mode, connect to the given network endpoint.
@@ -281,14 +280,14 @@ var (
281280
282281 fmt .Printf ("Using provider: %s (%s)\n " , machine .Provider , providerAddr )
283282 fmt .Printf ("Top-up machine: %s [%s]\n " , machineName , machine .ID )
284- fmt .Printf ("Top-up term: %d x %s\n " , topUpTermCount , topUpTerm )
283+ fmt .Printf ("Top-up term: %d x %s\n " , roflCommon . TermCount , roflCommon . Term )
285284
286285 // Prepare transaction.
287286 tx := roflmarket .NewInstanceTopUpTx (nil , & roflmarket.InstanceTopUp {
288287 Provider : * providerAddr ,
289288 ID : machineID ,
290289 Term : term ,
291- TermCount : topUpTermCount ,
290+ TermCount : roflCommon . TermCount ,
292291 })
293292
294293 acc := common .LoadAccount (cliConfig .Global (), npa .AccountName )
@@ -402,10 +401,6 @@ func showCommandArgs[V any](npa *common.NPASelection, raw []byte, args V) {
402401}
403402
404403func init () {
405- topUpFlags := flag .NewFlagSet ("" , flag .ContinueOnError )
406- topUpFlags .StringVar (& topUpTerm , "term" , roflCommon .TermMonth , "term to pay for in advance" )
407- topUpFlags .Uint64Var (& topUpTermCount , "term-count" , 1 , "number of terms to pay for in advance" )
408-
409404 showCmd .Flags ().AddFlagSet (common .SelectorFlags )
410405 showCmd .Flags ().AddFlagSet (roflCommon .DeploymentFlags )
411406
@@ -426,5 +421,5 @@ func init() {
426421 topUpCmd .Flags ().AddFlagSet (common .SelectorFlags )
427422 topUpCmd .Flags ().AddFlagSet (common .RuntimeTxFlags )
428423 topUpCmd .Flags ().AddFlagSet (roflCommon .DeploymentFlags )
429- topUpCmd .Flags ().AddFlagSet (topUpFlags )
424+ topUpCmd .Flags ().AddFlagSet (roflCommon . TermFlags )
430425}
0 commit comments