@@ -14,8 +14,9 @@ object CliCommands {
1414 val generatePrivateKeyCommand = " generate-private-key"
1515 val deriveAddressCommand = " derive-address"
1616 val generateAllocsCommand = " generate-allocs"
17- val useAddressesFlag = " useAddresses"
1817 val balanceOption = " balance"
18+ val keyOption = " key"
19+ val addressOption = " address"
1920
2021 private val GeneratePrivateKeyCommand : Command [String ] =
2122 Command (name = generatePrivateKeyCommand, header = " Generate private key" ) {
@@ -38,21 +39,17 @@ object CliCommands {
3839 private val GenerateAllocs : Command [String ] =
3940 Command (name = generateAllocsCommand, header = " Generate genesis allocs" ) {
4041
41- val useAddressesOpt : Opts [Boolean ] = Opts
42- .flag(long = useAddressesFlag, help = " Use addresses instead of private keys" )
43- .orFalse
42+ val keysOpt : Opts [NonEmptyList [String ]] =
43+ Opts
44+ .options[String ](long = keyOption, help = " Private key" )
45+ .map(_.map(key => privKeyToAddress(Hex .decode(key))))
4446
45- val keysOpt : Opts [NonEmptyList [String ]] = Opts .arguments [String ](" key " )
47+ val addressesOpt : Opts [NonEmptyList [String ]] = Opts .options [String ](long = addressOption, help = " Address " )
4648
4749 val balanceOpt =
4850 Opts .option[BigInt ](long = balanceOption, help = " Initial balance for account" , metavar = " balance" )
4951
50- val addresesOpt = (useAddressesOpt, keysOpt).mapN {
51- case (false , keys) => keys.map(key => privKeyToAddress(Hex .decode(key)))
52- case (true , keys) => keys
53- }
54-
55- (addresesOpt, balanceOpt).mapN { (addresses, balance) =>
52+ (keysOpt.orElse(addressesOpt), balanceOpt).mapN { (addresses, balance) =>
5653 allocs(addresses.toList, balance)
5754 }
5855 }
@@ -68,7 +65,7 @@ object CliCommands {
6865 Hex .toHexString(address)
6966 }
7067
71- val api : Command [String ] = Command .apply(name = " mantis- cli" , header = " Mantis CLI" ) {
68+ val api : Command [String ] = Command .apply(name = " cli" , header = " Mantis CLI" ) {
7269 Opts .subcommands(GeneratePrivateKeyCommand , DeriveAddressFromPrivateKey , GenerateAllocs )
7370 }
7471}
0 commit comments