aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorC. McEnroe <june@causal.agency>2019-09-16 17:09:49 -0400
committerC. McEnroe <june@causal.agency>2019-09-16 17:09:49 -0400
commit58a54e3b6b26827b979a1fe8d5bfe27eefdb46a9 (patch)
tree5dde175701cef896e9ed837cd54bceab5664c32b
parentAdd restricted mode (diff)
downloadcatgirl-58a54e3b6b26827b979a1fe8d5bfe27eefdb46a9.tar.gz
catgirl-58a54e3b6b26827b979a1fe8d5bfe27eefdb46a9.zip
Set default nick to USER unless -P
-rw-r--r--catgirl.117
-rw-r--r--chat.c10
2 files changed, 16 insertions, 11 deletions
diff --git a/catgirl.1 b/catgirl.1
index 51f1c4f..27b103b 100644
--- a/catgirl.1
+++ b/catgirl.1
@@ -8,7 +8,7 @@
.
.Sh SYNOPSIS
.Nm
-.Op Fl NRv
+.Op Fl NPRv
.Op Fl W Ar pass
.Op Fl a Ar auth
.Op Fl h Ar host
@@ -33,6 +33,9 @@ The arguments are as follows:
Send notifications with
.Xr notify-send 1 .
.
+.It Fl P
+Prompt for nickname.
+.
.It Fl R
Restrict the use of the
.Ic /join ,
@@ -83,6 +86,8 @@ in files named by date.
.It Fl n Ar nick
Set nickname to
.Ar nick .
+The default nickname
+is the user's name.
.
.It Fl p Ar port
Connect to
@@ -114,14 +119,6 @@ Log in with
.Ar pass .
.El
.
-.Pp
-If
-.Fl h Ar host
-or
-.Fl n Ar nick
-are not provided,
-they will be prompted for.
-.
.Sh COMMANDS
Any unique prefix
may be used to abbreviate a command.
@@ -367,6 +364,8 @@ to set the hostname
to the first word of
.Ev SSH_CLIENT ,
usually the client IP address.
+.It Ev USER
+The default nickname.
.El
.
.Sh EXAMPLES
diff --git a/chat.c b/chat.c
index 021ac77..7e1a9aa 100644
--- a/chat.c
+++ b/chat.c
@@ -53,9 +53,10 @@ int main(int argc, char *argv[]) {
setlocale(LC_CTYPE, "");
int opt;
- while (0 < (opt = getopt(argc, argv, "NRW:a:h:j:k:l:n:p:r:u:vw:"))) {
+ while (0 < (opt = getopt(argc, argv, "NPRW:a:h:j:k:l:n:p:r:u:vw:"))) {
switch (opt) {
break; case 'N': self.notify = true;
+ break; case 'P': self.nick = prompt("Name: ");
break; case 'R': self.limit = true;
break; case 'W': self.webp = dupe(optarg);
break; case 'a': self.auth = dupe(optarg);
@@ -73,9 +74,14 @@ int main(int argc, char *argv[]) {
}
}
+ if (!self.nick) {
+ const char *user = getenv("USER");
+ if (!user) errx(EX_USAGE, "USER unset");
+ self.nick = dupe(user);
+ }
+
if (!self.host) self.host = prompt("Host: ");
if (!self.port) self.port = dupe("6697");
- if (!self.nick) self.nick = prompt("Name: ");
if (!self.user) self.user = dupe(self.nick);
if (!self.real) self.real = dupe(self.nick);