Skip to content

Commit

Permalink
Add support for UID with -user '#...'
Browse files Browse the repository at this point in the history
Mm2PL committed Jan 27, 2023
1 parent 65417c5 commit df2b173
Showing 3 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion cmd/justgrep/justgrep.go
Original file line number Diff line number Diff line change
@@ -344,7 +344,11 @@ func main() {
}
var api justgrep.JustlogAPI
if *args.user != "" && !(*args.userIsRegex) {
api = &justgrep.UserJustlogAPI{User: *args.user, Channel: channel, URL: justlogUrl}
if (*args.user)[0] == '#' {
api = &justgrep.UserJustlogAPI{User: (*args.user)[1:], Channel: channel, URL: justlogUrl, IsId: true}
} else {
api = &justgrep.UserJustlogAPI{User: *args.user, Channel: channel, URL: justlogUrl}
}
} else {
api = &justgrep.ChannelJustlogAPI{Channel: channel, URL: justlogUrl}
}
4 changes: 3 additions & 1 deletion doc/justgrep.1.md
Original file line number Diff line number Diff line change
@@ -82,7 +82,9 @@ This tool searches the desired <i>justlog instance</i> for a regular expression
<dt><b>-notuser&#x00A0;</b>name</dt>
<dd>Ignores user identified by <i>name</i> from log searches. If
<i>-uregex</i> is used in combination, <b>name</b> is treated as a regular
expression.
expression. It's worth noting that search a single user's logs is much
faster than a whole channel. If the <b>name</b> isn't a regex and begins
with <i>#</i>, it will be treated as a user id.
<div class="Pp"></div>
</dd>
</dl>
3 changes: 2 additions & 1 deletion man1/justgrep.1
Original file line number Diff line number Diff line change
@@ -52,7 +52,8 @@ T}
.BR \-user\ name
Search logs for a single user. If \fI-uregex\fP is used in combination,
\fBname\fP is treated as a regular expression. It's worth noting that search a
single user's logs is much faster than a whole channel.
single user's logs is much faster than a whole channel. If the \fBname\fP isn't
a regex and begins with \fI#\fP, it will be treated as a user id.

.TP
.BR \-notuser\ name

0 comments on commit df2b173

Please sign in to comment.