Skip to content

Commit c4cb914

Browse files
committed
Update CLI output from nmqtt_password
1 parent 0e0e0a7 commit c4cb914

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

src/nmqtt_password.nim

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ from os import fileExists
66
from strutils import format, split
77
from terminal import readPasswordFromStdin
88

9+
import utils/version
10+
911

1012
proc addUserToFile(filename, username, password: string) =
1113
## Adds a new user
@@ -53,21 +55,18 @@ proc deleteUserToFile(filename, username: string) =
5355

5456
proc nmqttPassword(adduser=false, batch=false, deluser=false, args: seq[string]) =
5557
## Main handler
58+
echo "Running nmqtt_password v" & nmqttVersion
5659

5760
if args.len() == 0:
5861
echo "Error, missing parameters. Run again with --help."
5962
quit()
6063

61-
echo """
62-
nmqtt_broker v$1
63-
64-
Editing password_file
65-
- $2
66-
""".format("x.x.x", args[0])
64+
echo "\nEditing password_file\n - " & args[0] & "\n"
6765

6866
if adduser:
6967
if args.len() != 2:
70-
echo "Please provide a path to the password file and a username.\n"
68+
echo "Please provide a path to the password file and a username.\n" &
69+
" - nmqtt_password -a {password_file.conf} {username}"
7170
quit()
7271
let
7372
prompt = "Username: $1\nPassword: ".format(args[1])
@@ -76,13 +75,15 @@ Editing password_file
7675

7776
elif batch:
7877
if args.len() != 3:
79-
echo "Please provide a path to the password file, a username and password.\n"
78+
echo "Please provide a path to the password file, a username and password.\n" &
79+
" - nmqtt_password -b {password_file.conf} {username} {password}"
8080
quit()
8181
addUserToFile(args[0], args[1], args[2])
8282

8383
elif deluser:
8484
if args.len() != 2:
85-
echo "Please provide a path to the password file and a username.\n"
85+
echo "Please provide a path to the password file and a username.\n" &
86+
" - nmqtt_password -d {password_file.conf} {username}"
8687
quit()
8788
deleteUserToFile(args[0], args[1])
8889

@@ -92,7 +93,10 @@ Editing password_file
9293

9394

9495
when isMainModule:
95-
const topLvlUse = """${doc}
96+
const topLvlUse = """nmqtt_password is a user and password manager for nmqtt
97+
nmqtt_password is based upon nmqtt version """ & nmqttVersion & """
98+
99+
96100
USAGE
97101
$command -a {password_file.conf} {username}
98102
$command -b {password_file.conf} {username} {password}
@@ -107,12 +111,11 @@ $options
107111
clCfg.hTabCols = @[clOptKeys, clDescrip]
108112

109113
dispatchGen(nmqttPassword,
110-
doc="Add users and passwords to nmqtt's password file.",
111114
cmdName="nmqtt_password",
112115
help={
113116
"adduser": "add a new user to the password file.",
114117
"batch": "run in batch mode to allow passing passwords on the command line.",
115-
"deluser": "delete a user form the password file.",
118+
"deluser": "delete a user from the password file.",
116119
},
117120
short={
118121
"help": '?',

0 commit comments

Comments
 (0)