about summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--notemap.160
-rw-r--r--notemap.c5
2 files changed, 25 insertions, 40 deletions
diff --git a/notemap.1 b/notemap.1
index 1e187eb..0855524 100644
--- a/notemap.1
+++ b/notemap.1
@@ -1,4 +1,4 @@
-.Dd December 15, 2020
+.Dd December 16, 2020
 .Dt NOTEMAP 1
 .Os
 .
@@ -13,7 +13,7 @@
 .Op Fl h Ar host
 .Op Fl m Ar file
 .Op Fl p Ar port
-.Op Fl u Ar user
+.Ar user
 .Op Ar
 .
 .Sh DESCRIPTION
@@ -21,14 +21,27 @@ The
 .Nm
 utility
 mirrors text notes
-to an IMAP mailbox.
+to an IMAP mailbox
+appropriate for display
+by the Apple Notes application.
 Files are mapped to IMAP messages
-using a map file.
-If no files are given as arguments,
+using a map file,
+by default
+.Pa .notemap
+in the current directory.
+If no files are specified,
 all mapped files are mirrored.
+New files are added
+to the map file using
+.Fl a .
 .
 .Pp
-IMAP over TLS without STARTTLS is assumed.
+IMAP over TLS is assumed.
+The IMAP host and port
+are automatically discovered
+through SRV record lookup
+on the domain portion of
+.Ar user .
 The password is read from
 .Pa /dev/tty ,
 or standard input if
@@ -43,58 +56,29 @@ Mirror notes to
 .Ar mailbox .
 The default is
 .Sy Notes .
-.
 .It Fl a
 Add new notes to the map file.
-.
 .It Fl f
-Overwrite notes which have changed in the mailbox.
-.
+Overwrite modified notes in the mailbox.
 .It Fl h Ar host
 Connect to IMAP on
 .Ar host .
-The default host is determined
-by SRV record lookup on the domain of
-.Ar user ,
-or simply the domain name
-if no SRV record exists.
-.
 .It Fl m Ar file
-Set the location of the map file.
+Set the path of the map file.
 The default is
 .Pa .notemap .
-.
 .It Fl p Ar port
 Connect to IMAP on
 .Ar port .
-If the
-.Fl h
-option is used,
-the default port is
-.Sy imaps
-(993).
-Otherwise,
-the port is determined
-in the same fashion as the host.
-.
-.It Fl u Ar user
-Log in to IMAP as
-.Ar user .
-The IMAP connection information
-is inferred from the username unless
-.Fl h
-is used.
-.
 .It Fl v
 Log IMAP protocol to standard error.
-.
 .It Fl w
 Read the password from standard input.
 .El
 .
 .Sh EXAMPLES
 .Bd -literal
-notemap -a -u june@causal.agency note.txt
+notemap -a june@causal.agency note.txt
 .Ed
 .
 .Sh STANDARDS
diff --git a/notemap.c b/notemap.c
index e2b41dc..a1d280c 100644
--- a/notemap.c
+++ b/notemap.c
@@ -167,7 +167,7 @@ int main(int argc, char *argv[]) {
 	int rppFlags = 0;
 
 	int opt;
-	while (0 < (opt = getopt(argc, argv, "M:afh:m:p:u:vw"))) {
+	while (0 < (opt = getopt(argc, argv, "M:afh:m:p:vw"))) {
 		switch (opt) {
 			break; case 'M': mailbox = optarg;
 			break; case 'a': add = true;
@@ -181,10 +181,11 @@ int main(int argc, char *argv[]) {
 			break; default:  return EX_USAGE;
 		}
 	}
-	if (!user) errx(EX_USAGE, "username required");
+	if (optind < argc) user = argv[optind++];
 	argv += optind;
 	argc -= optind;
 	
+	if (!user) errx(EX_USAGE, "username required");
 	if (!host) {
 		host = strchr(user, '@');
 		if (!host) errx(EX_USAGE, "no domain in username");