29 lines
433 B
Go
29 lines
433 B
Go
|
package io
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"math/big"
|
||
|
"os"
|
||
|
)
|
||
|
|
||
|
type Cliargs struct {
|
||
|
value *big.Int
|
||
|
}
|
||
|
|
||
|
func (arg *Cliargs) Parse() error {
|
||
|
args := os.Args[1:]
|
||
|
if len(args) != 1 {
|
||
|
return errors.New("only expected 1 arg")
|
||
|
}
|
||
|
num, success := new(big.Int).SetString(args[0], 10)
|
||
|
if !success {
|
||
|
return errors.New("argument is not an integer")
|
||
|
}
|
||
|
arg.value = num
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (arg *Cliargs) GetNumber() *big.Int {
|
||
|
return arg.value
|
||
|
}
|