about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorlogin (__tcoin) (tilde.my.to) <login@tilde.my.to>2021-02-03 13:44:07 +0000
committerlogin (__tcoin) (tilde.my.to) <login@tilde.my.to>2021-02-03 13:44:07 +0000
commit2e22b08ff724c1fcdf7daad1ee201bcf944bcbc2 (patch)
tree112dca539a2283678de19baaee16862b76e1d484
parent0e3853cdf5a995b9bec9f8dade58f5f98b3df74f (diff)
downloadtcoin-2e22b08ff724c1fcdf7daad1ee201bcf944bcbc2.tar.gz
Better way to handle 5 arguments
Improved the way 5 arguments were handled, where the intention was to
send a message along with the amount and receiver, with a new error code
and a slightly modified error message.
-rw-r--r--pcoin.cpp7
-rw-r--r--tcoin.cpp7
2 files changed, 8 insertions, 6 deletions
diff --git a/pcoin.cpp b/pcoin.cpp
index 5bf1b79..b6f2f8f 100644
--- a/pcoin.cpp
+++ b/pcoin.cpp
@@ -55,6 +55,7 @@
 
 #define ERR_MAIN_SEND_TOO_FEW_ARGS 6
 #define ERR_MAIN_SEND_TOO_MANY_ARGS 7
+#define ERR_MAIN_SEND_TOO_MANY_ARGS_MSG 104
 #define ERR_SILENTSEND 2
 #define ERR_MAIN_MSG_TOO_LONG 19
 #define ERR_UNKNOWN_ARG 3
@@ -1942,8 +1943,9 @@ int main(int argc, char *argv[])
       }
       else
       {
-        //too many command-line arguments were passed (6 args)
-        goto LABEL_TOO_MANY_ARGS;
+        //too many command-line arguments were passed (6 args) (probably a message was intended)
+        std::cout << "\nSorry, too many command-line arguments were passed. The correct format is `tcoin send <username> <amount> \"<message>\"`.\n\n";
+        return ERR_MAIN_SEND_TOO_MANY_ARGS_MSG;
       }
     }
     else if(argc < 4)
@@ -1953,7 +1955,6 @@ int main(int argc, char *argv[])
     }
     else if(argc > 4)
     {
-      LABEL_TOO_MANY_ARGS:
       std::cout << "\nSorry, too many command-line arguments were passed. The correct format is `" << PCOIN_BIN_PATH_W_SPACE << "send <username> <amount>`.\n\n";
       return ERR_MAIN_SEND_TOO_MANY_ARGS;
     }
diff --git a/tcoin.cpp b/tcoin.cpp
index a382746..faeb617 100644
--- a/tcoin.cpp
+++ b/tcoin.cpp
@@ -64,6 +64,7 @@
 #define ERR_NOT_LOGGED_IN 5
 #define ERR_MAIN_SEND_TOO_FEW_ARGS 6
 #define ERR_MAIN_SEND_TOO_MANY_ARGS 7
+#define ERR_MAIN_SEND_TOO_MANY_ARGS_MSG 104
 #define ERR_MAIN_MSG_TOO_LONG 19
 #define ERR_SILENTSEND 2
 #define ERR_UNKNOWN_ARG 3
@@ -1800,8 +1801,9 @@ int main(int argc, char *argv[])
       }
       else
       {
-        //too many command-line arguments were passed (6 args)
-        goto LABEL_TOO_MANY_ARGS;
+        //too many command-line arguments were passed (6 args) (probably a message was intended)
+        std::cout << "\nSorry, too many command-line arguments were passed. The correct format is `tcoin send <username> <amount> \"<message>\"`.\n\n";
+        return ERR_MAIN_SEND_TOO_MANY_ARGS_MSG;
       }
     }
     else if(argc < 4)
@@ -1811,7 +1813,6 @@ int main(int argc, char *argv[])
     }
     else if(argc > 4)
     {
-      LABEL_TOO_MANY_ARGS:
       std::cout << "\nSorry, too many command-line arguments were passed. The correct format is `tcoin send <username> <amount>`.\n\n";
       return ERR_MAIN_SEND_TOO_MANY_ARGS;
     }