All commands
Every command Namjai has, how a command is put together, and what its exit code means.
The shape of a command
Every command you type starts with nj, the short name of the namjai command (both names do the same). The WhatsApp commands look like this:
wp stands for WhatsApp. The command says what you want to know, such as waiting. Some commands take words: a name to find, a chat to read, text to search for, a label. Options start with two dashes, such as --limit 5, and change the answer. One dash works too (-limit 5), and so does an equals sign (--limit=5).
Options can go before or after the words: nj wp search hotel --limit 3 and nj wp search --limit 3 hotel do the same. Two dashes alone, --, end the options: everything after them is words, even if it starts with a dash. To search for the text --limit:
nj wp search -- --limit0 messages
Each WhatsApp command takes only the options its section lists. Any other option is refused with one line that names the options it does take, such as nj wp waiting: --missed is not an option of this command; it takes --at-least, --csv, --format, --json, --limit, --table, --text, --within, and exit code 2. Two different formats together are refused too (nj wp find: choose one format, not both --csv and --json); the same one twice is fine.
| Command | Options it takes, beside the format options |
|---|---|
find, read, new, labelled | --limit |
search | --chat, --limit |
waiting, unanswered | --at-least, --within, --limit |
archived, new-customers | --within, --limit |
calls | --missed, --limit |
count | --chat |
labels | none |
doctor | none, and no format options either |
send | --dry-run, --new, and no format options |
send-setup | none, and no format options either |
The format options are --text, --table, --csv, --json and --format name.
Every command
| Command | What it does |
|---|---|
nj wp waiting | Who is waiting for your answer, and how long |
nj wp unanswered | Who has not answered you |
nj wp new | Chats with unread messages |
nj wp archived | Archived chats that are still active |
nj wp new-customers | Chats whose first message is recent |
nj wp find | Find a contact or chat |
nj wp read | Read a chat |
nj wp search | Search your messages |
nj wp calls | Your calls, or only the missed ones |
nj wp labels | Your labels, with how many chats carry each |
nj wp labelled | The chats under one label |
nj wp count | Your messages counted by kind |
nj wp send | Send a message to one person, and check that it arrived |
nj wp send-setup | Switch sending on, when the Add Shortcut window of the installer or of setup was closed without a click |
nj setup | Connect Namjai to WhatsApp on this Mac and save the settings |
nj wp doctor | Health check: every line says ok, FAIL or -- |
nj set format | Choose the format every wp command prints by default |
nj update | Put the newest version on this Mac; --check only looks |
nj set download | Save the address nj update downloads from |
nj remove | Take Namjai off this Mac; --dry-run only lists |
nj version | Which version you have |
nj help | The list of commands |
nj help settings | The commands and settings for developers |
nj wp sync | For developers: send the chats marked client to a Namjai server |
nj demo send | For developers: send made-up demo data to a Namjai server |
Exit codes
When a command ends, it leaves a number, its exit code, which a script can read (echo $? right after the command prints it).
| Code | Means | When |
|---|---|---|
| 0 | It worked | The answer was printed, even when it is empty (0 chats). nj wp doctor and nj setup when no line says FAIL. nj alone, nj help, nj wp, --help after any command, nj version, nj set format with a known format, nj set download with an address, nj update and nj update --check whether or not a newer version is there. |
| 1 | It could not finish | WhatsApp's files could not be opened or read; a chat name, number or chat ID matched no chat, or a name matched several (read, search --chat, count --chat); the call or label file is missing; a health check line says FAIL; setup could not find WhatsApp, was not allowed to read it, could not read the Mac's own time zone (no --time-zone given) or could not save; a send to a server failed; nj wp send refused the chat, found no shortcut, or could not find the message once in the right chat afterwards; nj update has no download address, could not read or download the newest version, found the download did not match, or the install did not finish. |
| 2 | The command was not understood, or a setting is missing | An unknown command, an unknown option, a value it cannot use, words missing or words given to a command that takes none (such as nj version extra), a --time-zone that is not a time zone name, a format that is not text, table, csv or json, and a setting that is missing or wrong (the message starts with nj: configuration:). |
Where errors are printed
Answers go to the normal output. Errors go to the error output, so nj wp waiting --csv > ~/waiting.csv still shows an error on the screen instead of writing it into the file. An error names the command it comes from, such as nj wp read: no chat matches "nobody". To list every chat: nj wp find. Two commands are different: nj wp doctor prints its FAIL lines as normal output, and nj setup prints its steps as normal output and its errors as error output.
nj wp read: no chat matches "nobody". To list every chat: nj wp find
A mistake in a command it knows (a bad value, an option the command does not take, a stray word, a missing word) prints one line that says what was wrong, then See: nj help, and exits with 2. A command it does not know prints one line that names the word, then See: nj help, and exits with 2. Version 0.2.8 and older printed the list of commands instead.
nj wp bogusnj wp: "bogus" is not a command See: nj help
The list of commands is printed, with exit code 0, by nj alone, nj help, nj wp and --help after any command. nj help prints the list:
nj helpNamjai reads the WhatsApp on this computer, and sends a WhatsApp message
only when you run nj wp send. Nothing else leaves this computer unless
you set up a Namjai server: see nj help settings.
First time nj setup
Health check nj wp doctor
Newest version nj update; nj update --check only looks
the installer says where to look; nj set download ADDRESS changes it
Remove it nj remove; nj remove --dry-run only lists, --yes does not ask
nj wp waiting who is waiting for your answer, and how long
nj wp unanswered who has not answered you
nj wp new chats with unread messages
nj wp find NAME find a contact or chat
nj wp read NAME read a chat
nj wp search WORDS search your messages
nj wp calls calls; add --missed for missed calls only
nj wp new-customers chats that started this week
nj wp labels your labels; nj wp labelled LABEL for the chats under one
nj wp archived archived chats that are still active
nj wp count messages by type
nj wp send CHAT "TEXT" send to one person; --dry-run to check first, --new for a new number
nj wp send-setup switch sending on, if setup's Add Shortcut was not clicked
Options can go before or after the name or words:
--limit 200 show more than 50 lines
--within 30d look back 30 days instead of 7 (waiting, unanswered, archived, new-customers)
--at-least 2h only people waiting 2 hours or more (waiting, unanswered)
--chat NAME search or count in one chat
--table, --csv, --json the same result as a table, as CSV or as JSON, for a program to read
--text plain lines again, when another format is the default
--within 0 no time limit
To make one of them the default: nj set format json (text, table, csv or json)
More: nj version, nj help settings
Short name: type nj instead of namjai.