From d518ff941af377beb87288efbfaef4e25b251f58 Mon Sep 17 00:00:00 2001
From: Moul <moul@moul.re>
Date: Mon, 24 Jun 2019 23:46:14 +0200
Subject: [PATCH] [enh] #235: tx: use Mutually exclusive for amount, amountUD,
 allSources options

---
 silkaj/tx.py | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/silkaj/tx.py b/silkaj/tx.py
index 0c0bee9a..697db261 100644
--- a/silkaj/tx.py
+++ b/silkaj/tx.py
@@ -18,9 +18,10 @@ along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
 from re import compile, search
 import math
 from time import sleep
+from tabulate import tabulate
 from click import command, option, FloatRange
 
-from tabulate import tabulate
+from silkaj.cli_tools import MutuallyExclusiveOption
 from silkaj.network_tools import ClientInstance, HeadBlock
 from silkaj.crypto_tools import check_public_key
 from silkaj.tools import message_exit, CurrencySymbol, coroutine
@@ -40,9 +41,27 @@ from duniterpy.documents.transaction import OutputSource, Unlock, SIGParameter
 
 
 @command("tx", help="Send transaction")
-@option("--amount", type=FloatRange(0.01), help="Quantitative value")
-@option("--amountUD", type=float, help="Relative value")
-@option("--allSources", is_flag=True, help="Send all sources")
+@option(
+    "--amount",
+    type=FloatRange(0.01),
+    help="Quantitative value",
+    cls=MutuallyExclusiveOption,
+    mutually_exclusive=["amountud", "allsources"],
+)
+@option(
+    "--amountUD",
+    type=float,
+    help="Relative value",
+    cls=MutuallyExclusiveOption,
+    mutually_exclusive=["amount", "allsources"],
+)
+@option(
+    "--allSources",
+    is_flag=True,
+    help="Send all sources",
+    cls=MutuallyExclusiveOption,
+    mutually_exclusive=["amount", "amountud"],
+)
 @option(
     "--output",
     required=True,
-- 
GitLab