2024-04-24 20:04:34 +00:00
|
|
|
package parsing
|
2024-04-24 17:49:03 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"math/big"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Cliargs struct {
|
|
|
|
}
|
|
|
|
|
2024-04-24 17:53:00 +00:00
|
|
|
func (arg *Cliargs) Parse() (*big.Int, error) {
|
2024-04-24 17:49:03 +00:00
|
|
|
args := os.Args[1:]
|
|
|
|
if len(args) != 1 {
|
2024-04-24 17:53:00 +00:00
|
|
|
return nil, errors.New("only expected 1 arg")
|
2024-04-24 17:49:03 +00:00
|
|
|
}
|
|
|
|
num, success := new(big.Int).SetString(args[0], 10)
|
|
|
|
if !success {
|
2024-04-24 17:53:00 +00:00
|
|
|
return nil, errors.New("argument is not an integer")
|
2024-04-24 17:49:03 +00:00
|
|
|
}
|
2024-04-24 17:53:00 +00:00
|
|
|
return num, nil
|
2024-04-24 17:49:03 +00:00
|
|
|
}
|