Skip to content

Commit f385372

Browse files
author
NullpointerW
committed
cmd
1 parent 8cc664a commit f385372

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ EthereumWalletTool
88
go build ehtwt.exe/ethwt
99
```
1010
## usage
11+
Command help:
12+
```shell
13+
ehtwt.exe --help
14+
```
1115
1. Configure the primary wallet key in the `.PK` file.
1216
2. Generate a specified number of wallets in bulk,and Wallet information will be logged as JSON.
1317
```shell

cmd.go

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ import (
44
"fmt"
55
"github.com/spf13/cobra"
66
"os"
7+
"strconv"
78
)
89

9-
var (
10-
WallNum int
11-
Val string
12-
)
10+
//var (
11+
// WallNum int
12+
// Val string
13+
//)
1314

1415
var ethwt = &cobra.Command{
1516
Use: "ethwt",
@@ -23,16 +24,31 @@ var gen = &cobra.Command{
2324
Use: "gen",
2425
Short: "Generate wallet",
2526
Run: func(cmd *cobra.Command, args []string) {
26-
GenWallet(WallNum)
27+
wallNum := 0
28+
if len(args) > 0 {
29+
var err error
30+
wallNum, err = strconv.Atoi(args[0])
31+
if err != nil {
32+
fmt.Println("generate wallet failed:", err)
33+
return
34+
}
35+
}
36+
GenWallet(wallNum)
2737
},
38+
Args: cobra.MinimumNArgs(1),
2839
}
2940

3041
var tx = &cobra.Command{
3142
Use: "tx",
3243
Short: "Transfer to wallets",
3344
Run: func(cmd *cobra.Command, args []string) {
34-
Transfer(Val)
45+
val := "0"
46+
if len(args) > 0 {
47+
val = args[0]
48+
}
49+
Transfer(val)
3550
},
51+
Args: cobra.MinimumNArgs(1),
3652
}
3753

3854
var pa = &cobra.Command{
@@ -44,8 +60,8 @@ var pa = &cobra.Command{
4460
}
4561

4662
func init() {
47-
tx.Flags().StringVarP(&Val, "val", "v", "0", "Value amount of ETH for each transfer")
48-
gen.Flags().IntVarP(&WallNum, "walletNum", "n", 1, "The number of wallets generated")
63+
//tx.Flags().StringVarP(&Val, "val", "v", "0", "Value amount of ETH for each transfer")
64+
//gen.Flags().IntVarP(&WallNum, "walletNum", "n", 1, "The number of wallets generated")
4965
ethwt.AddCommand(tx, gen, pa)
5066
}
5167

0 commit comments

Comments
 (0)