diff options
author | B. Watson <yalhcru@gmail.com> | 2021-06-20 16:19:20 -0400 |
---|---|---|
committer | B. Watson <yalhcru@gmail.com> | 2021-06-20 16:19:20 -0400 |
commit | 5d5c353f1c9a66064bb4914ab405b8f50d21572b (patch) | |
tree | 9ddc1b66c8e484dc192d53452f897b5e5e5ff5d4 | |
parent | ac5b748e29b24bf95311417b1efed2b91c2b0ee6 (diff) | |
download | limnoria.slackfacts.plugins-5d5c353f1c9a66064bb4914ab405b8f50d21572b.tar.gz |
SlackTools: rename pkgsrc => srcsearch, add pkg -s option
-rw-r--r-- | SlackTools/plugin.py | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/SlackTools/plugin.py b/SlackTools/plugin.py index c4b0e7d..f6c0484 100644 --- a/SlackTools/plugin.py +++ b/SlackTools/plugin.py @@ -164,19 +164,28 @@ class SlackTools(callbacks.Plugin): filesearch = thread(wrap(filesearch, ['somethingWithoutSpaces'])) # run filesearch or pkgsearch, save some typing. - def pkg(self, irc, msg, args, fileflag, term): - """ [-f] <file-or-package> + def pkg(self, irc, msg, args, flag, term): + """ [-f|-s] <file-or-package> - Without -f, same as pkgsearch. With -f, same as filesearch. - See the help for pkgsearch and/or filesearch for details. + Without no argument, same as pkgsearch. With -f, same as filesearch. + With -s, same as srcsearch. + See the help for pkgsearch, filesearch, srcsearch for details. """ - if(fileflag): + if(term is None): + term = flag + flag = '-p' + + if(flag == '-f'): self.PkgQuery(irc, msg, 'file', term) - else: + elif(flag == '-p'): self.PkgQuery(irc, msg, 'pkg', term) + elif(flag == '-s'): + self.PkgSrc(irc, msg, args, term) + else: + irc.error("invalid option '" + flag + "'") - pkg = thread(wrap(pkg, [optional(('literal', ['-f'])), 'somethingWithoutSpaces'])) + pkg = thread(wrap(pkg, ['somethingWithoutSpaces', optional('somethingWithoutSpaces')])) def FileQuery(self, irc, msg, term): db = self.InitDB(); @@ -258,24 +267,26 @@ class SlackTools(callbacks.Plugin): return None + def PkgSrc(self, irc, msg, args, pkg): + url = self.FindSrc(pkg) + if (url is None): + irc.reply("no source found for " + pkg) + else: + irc.reply(url) + # fun fact: there's no source dir for the kernel-source package! # if there's not an individual source dir for an x11/ package, # we get source/x/x11/ as the result. That's where x11.SlackBuild # lives, so it's correct. - def pkgsrc(self, irc, msg, args, pkg): + def srcsearch(self, irc, msg, args, pkg): """ <package> Find the URL for the source directory of a Slackware package. This is the directory containing the SlackBuild. The package name is searched for first in patches/, and then the main slackware64/. """ + self.PkgSrc(irc, msg, args, pkg) - url = self.FindSrc(pkg) - if (url is None): - irc.reply("no source found for " + pkg) - else: - irc.reply(url) - - pkgsrc = thread(wrap(pkgsrc, ['somethingWithoutSpaces'])) + srcsearch = thread(wrap(srcsearch, ['somethingWithoutSpaces'])) Class = SlackTools |