]> PatchyGit - patchyircd.git/commitdiff
setpass: add error messages
authorEgor <egor@patchysicp.xyz>
Sun, 15 Jun 2025 05:04:08 +0000 (08:04 +0300)
committerEgor <egor@patchysicp.xyz>
Sun, 15 Jun 2025 05:04:08 +0000 (08:04 +0300)
src/setpass.cpp

index 4aa4b41..c86d306 100644 (file)
@@ -30,10 +30,16 @@ char *read_password(const char *prompt)
 
 int main(int argc, char **argv)
 {
-       if (argc < 3)
+       if (argc < 3) {
+               fprintf(stderr, "Usage: %s [username] [datafile.txt]\n", argv[0]);
                return 1;
+       }
        char *pass = read_password("password: ");
        if (!pass)
                return 1;
-       return -password_set(argv[1], pass, argv[2], "setpass.tmp");
+       if (password_set(argv[1], pass, argv[2], "setpass.tmp") == -1) {
+               fprintf(stderr, "There was an error. Does %s exist?\n", argv[2]);
+               return 1;
+       }
+       return 0;
 }