/usr/share/pyshared/pgxnclient/commands/help.py is in pgxnclient 1.0.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | """
pgxnclient -- help commands implementation
"""
# Copyright (C) 2011 Daniele Varrazzo
# This file is part of the PGXN client
import os
from pgxnclient import get_scripts_dirs, get_public_scripts_dir
from pgxnclient.i18n import _, N_
from pgxnclient.commands import Command
class Help(Command):
name = 'help'
description = N_("display help and other program information")
@classmethod
def customize_parser(self, parser, subparsers, **kwargs):
subp = super(Help, self).customize_parser(
parser, subparsers, **kwargs)
g = subp.add_mutually_exclusive_group()
g.add_argument('--all', action="store_true",
help = _("list all the available commands"))
g.add_argument('--libexec', action="store_true",
help = _("print the location of the scripts directory"))
g.add_argument('command', metavar='CMD', nargs='?',
help = _("the command to get help about"))
# To print the basic help
self._parser = parser
return subp
def run(self):
if self.opts.command:
from pgxnclient.cli import main
main([self.opts.command, '--help'])
elif self.opts.all:
self.print_all_commands()
elif self.opts.libexec:
self.print_libexec()
else:
self._parser.print_help()
def print_all_commands(self):
cmds = self.find_all_commands()
title = _("Available PGXN Client commands")
print title
print "-" * len(title)
for cmd in cmds:
print " " + cmd
def find_all_commands(self):
rv = []
path = os.environ.get('PATH', '').split(os.pathsep)
path[0:0] = get_scripts_dirs()
for p in path:
if not os.path.isdir(p):
continue
for fn in os.listdir(p):
if fn.startswith('pgxn-'):
rv.append(fn[5:])
rv.sort()
return rv
def print_libexec(self):
print get_public_scripts_dir()
|