[bisq-network/bisq] [WIP] Change api method params to posix-style opts (#5079)

Stan notifications at github.com
Wed Jan 13 01:18:27 CET 2021


Posix-style method opts replace the formerly ambiguous, positional method params in the CLI.  The opts parsing lib used also adds some much needed client side method param validation.

This change also adds new api `CoreHelpService` for serving method specific help from the server.  Help text is defined on the server to avoid duplicating it when the api starts serving RESTful clients.

To see `takeoffer` method help, run:   `./bisq-cli --password=xyz --port=9998 -m=takeoffer -help` 
The output will probably change, but here is what it looks like now:
```
takeoffer

Takes an existing offer for a matching payment method.  The Bisq trade fee can be paid in BSQ or BTC.

Usage: -m=takeoffer -o=offer-id -p=payment-acct-id [-c=taker-fee-currency-code = bsq|btc]

Parameters:
-o=offer-id                   (required)                  The ID of the offer being taken.
-i=payment-acct-id            (required)                  The ID of the payment account to be used in the trade.
-c=taker-fee-currency-code    (optional, default=BTC)     The Bisq trade taker fee currency (BSQ or BTC).

Example:
To take an offer with ID f2930107-7e67-4006-b92c-4f2cebef9376 using matching payment account with ID f0f02d74-6a9a-4dca-80c9-7216b2c4d8bc, paying the Bisq trading fee in BSQ:
./bisq-cli --password=xyz --port=9998 -m=takeoffer  -o=f2930107-7e67-4006-b92c-4f2cebef9376  -p=f0f02d74-6a9a-4dca-80c9-7216b2c4d8bc  -c=bsq
```



This is the 4th in a chain of PRs, starting with https://github.com/bisq-network/bisq/pull/5063.  
https://github.com/bisq-network/bisq/pull/5076 should be reviewed & merged before this one.
You can view, comment on, or merge this pull request online at:

  https://github.com/bisq-network/bisq/pull/5079

-- Commit Summary --

  * Fix two CLI option parsing bugs
  * Add @Singleton annotation
  * Integrate new protection tools into api's offer & trade services
  * Merge branch 'master' into 03-support-trigger-price
  * Stub out support for OpenOffer's triggerPrice in api
  * Display fiat ccy code in upper case
  * Merge branch 'master' into 03-support-trigger-price
  * Move CLI method enum to its own class
  * Add gRPC service Help definition
  * Add new GrpcHelpService boilerplate
  * Add HelpService to gRPC Server
  * Stub out new api CoreHelpService
  * Add gRPC client stub for help
  * Add CLI method specific posix-style option parsers
  * Use posix-style method options in CLI
  * Delete NegativeNumberOptions class
  * Add opt parser for no-arg methods (to detect method help opt)
  * Use no-arg method opt parser in CLI (detect method help opt)
  * Add basic help for no-arg methods
  * Short circuit method opt validation if user wants help
  * Add 1st cut of takeoffer method help
  * Remove position number info from method param desc

-- File Changes --

    M cli/src/main/java/bisq/cli/CliMain.java (508)
    M cli/src/main/java/bisq/cli/CurrencyFormat.java (11)
    M cli/src/main/java/bisq/cli/GrpcStubs.java (3)
    A cli/src/main/java/bisq/cli/Method.java (56)
    D cli/src/main/java/bisq/cli/NegativeNumberOptions.java (83)
    M cli/src/main/java/bisq/cli/TableFormat.java (2)
    A cli/src/main/java/bisq/cli/opts/AbstractMethodOptionParser.java (52)
    A cli/src/main/java/bisq/cli/opts/ArgumentList.java (118)
    A cli/src/main/java/bisq/cli/opts/CancelOfferOptionParser.java (51)
    A cli/src/main/java/bisq/cli/opts/CreateOfferOptionParser.java (138)
    A cli/src/main/java/bisq/cli/opts/CreatePaymentAcctOptionParser.java (61)
    A cli/src/main/java/bisq/cli/opts/GetAddressBalanceOptionParser.java (51)
    A cli/src/main/java/bisq/cli/opts/GetBalanceOptionParser.java (42)
    A cli/src/main/java/bisq/cli/opts/GetOfferOptionParser.java (51)
    A cli/src/main/java/bisq/cli/opts/GetOffersOptionParser.java (62)
    A cli/src/main/java/bisq/cli/opts/GetPaymentAcctFormOptionParser.java (51)
    A cli/src/main/java/bisq/cli/opts/GetTradeOptionParser.java (60)
    A cli/src/main/java/bisq/cli/opts/GetTransactionOptionParser.java (51)
    A cli/src/main/java/bisq/cli/opts/MethodOpts.java (26)
    A cli/src/main/java/bisq/cli/opts/RegisterDisputeAgentOptionParser.java (62)
    A cli/src/main/java/bisq/cli/opts/RemoveWalletPasswordOptionParser.java (51)
    A cli/src/main/java/bisq/cli/opts/SendBsqOptionParser.java (70)
    A cli/src/main/java/bisq/cli/opts/SendBtcOptionParser.java (78)
    A cli/src/main/java/bisq/cli/opts/SetTxFeeRateOptionParser.java (51)
    A cli/src/main/java/bisq/cli/opts/SetWalletPasswordOptionParser.java (59)
    A cli/src/main/java/bisq/cli/opts/SimpleMethodOptionParser.java (30)
    A cli/src/main/java/bisq/cli/opts/TakeOfferOptionParser.java (70)
    A cli/src/main/java/bisq/cli/opts/UnlockWalletOptionParser.java (63)
    A cli/src/main/java/bisq/cli/opts/WithdrawFundsOptionParser.java (67)
    M core/src/main/java/bisq/core/api/CoreApi.java (19)
    A core/src/main/java/bisq/core/api/CoreContext.java (39)
    M core/src/main/java/bisq/core/api/CoreDisputeAgentsService.java (2)
    A core/src/main/java/bisq/core/api/CoreHelpService.java (136)
    M core/src/main/java/bisq/core/api/CoreOffersService.java (27)
    M core/src/main/java/bisq/core/api/CorePaymentAccountsService.java (2)
    M core/src/main/java/bisq/core/api/CorePriceService.java (3)
    M core/src/main/java/bisq/core/api/CoreTradesService.java (9)
    M core/src/main/java/bisq/core/api/CoreWalletsService.java (2)
    M core/src/main/java/bisq/core/api/model/OfferInfo.java (25)
    A daemon/src/main/java/bisq/daemon/grpc/GrpcHelpService.java (56)
    M daemon/src/main/java/bisq/daemon/grpc/GrpcOffersService.java (5)
    M daemon/src/main/java/bisq/daemon/grpc/GrpcServer.java (2)
    M proto/src/main/proto/grpc.proto (39)

-- Patch Links --

https://github.com/bisq-network/bisq/pull/5079.patch
https://github.com/bisq-network/bisq/pull/5079.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/5079
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20210112/e51d6d96/attachment-0001.htm>


More information about the bisq-github mailing list