def test_get_version(): get_version = github.version.get_version for tup, short, normal, verbose in [ ((0, 2, 0, 'final', 0), '0.2.0', '0.2', '0.2 final'), ((0, 2, 7, 'final', 0), '0.2.7', '0.2.7', '0.2.7 final'), ((0, 2, 0, 'alpha', 1), '0.2a1', '0.2 alpha 1', '0.2 alpha 1'), ((0, 2, 7, 'beta', 1), '0.2.7b1', '0.2.7 beta 1', '0.2.7 beta 1'), ((0, 2, 0, 'release candidate', 1), '0.2rc1', '0.2 release candidate 1', '0.2 release candidate 1'), ((1, 0, 0, 'alpha', 0), '1.0a', '1.0 pre-alpha', '1.0 pre-alpha'), ]: github.version.VERSION = tup yield eq_, get_version('short'), short yield eq_, get_version('normal'), normal yield eq_, get_version('verbose'), verbose
from setuptools import setup, find_packages description = "A command-line interface to the GitHub Issues API v2." cur_dir = os.path.dirname(__file__) try: long_description = open(os.path.join(cur_dir, 'README.rst')).read() except: long_description = description # needed for importing github.version sys.path.insert(0, os.path.join(cur_dir, 'src')) from github.version import get_version setup( name = "github-cli", version = get_version('short'), url = 'http://packages.python.org/github-cli', license = 'BSD', description = description, long_description = long_description, author = 'Sander Smits', author_email = '*****@*****.**', packages = find_packages('src'), package_dir = {'': 'src'}, install_requires = ['setuptools', 'simplejson'], entry_points=""" [console_scripts] ghi = github.issues:main """, classifiers=[ 'Development Status :: 4 - Beta',
def main(): usage = """usage: %prog command [args] [options] Examples: %prog list [-s open|closed|all] show open, closed or all issues (default: open) %prog [-s o|c|a] -v same as above, but with issue details %prog same as: %prog list %prog -v same as: %prog list -v %prog [-s o|c] -w show issues' GitHub page in web browser (default: open) %prog list -u <github_user> show issues created by specified user %prog show <nr> show issue <nr> %prog show <nr> -v same as above, but with comments %prog <nr> same as: %prog show <nr> %prog <nr> -w show issue <nr>'s GitHub page in web browser %prog open (o) create a new issue (with $EDITOR) %prog open (o) -m <msg> create a new issue with <msg> content (optionally, use \\n for new lines; first line will be the issue title) %prog close (c) <nr> close issue <nr> %prog open (o) <nr> reopen issue <nr> %prog edit (e) <nr> edit issue <nr> (with $EDITOR) %prog label add (al) <label> <nr> add <label> to issue <nr> %prog label remove (rl) <label> <nr> remove <label> from issue <nr> %prog search (s) <term> search for <term> (default: open) %prog s <term> [-s o|c] -v same as above, but with details %prog s <term> -s closed only search in closed issues %prog comment (m) <nr> create a comment for issue <nr> (with $EDITOR) %prog comment (m) <nr> -m <msg> create a comment for issue <nr> with <msg> content. (optionally use \\n for new lines) %prog -r <user>/<repo> specify a repository (can be used for all commands) %prog -r <repo> specify a repository (gets user from global git config)""" description = """Description: command-line interface to GitHub's Issues API (v2)""" parser = OptionParser(usage=usage, description=description) parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="show issue details (only for show, list and "\ "search commands) [default: False]") parser.add_option("-s", "--state", action="store", dest="state", type='choice', choices=['o', 'open', 'c', 'closed', 'a', 'all'], default='open', help="specify state (only for list and search "\ "(except `all`) commands) choices are: open (o), closed (c), all "\ "(a) [default: open]") parser.add_option("-u", "--user", action="store", dest="created_by", default=False,\ help="issues created by <github_username> [default: all]") parser.add_option("-m", "--message", action="store", dest="message", default=None, help="message content for opening or commenting on an "\ "issue without using the editor") parser.add_option("-r", "--repo", "--repository", action="store", dest="repo", help="specify a repository (format: "\ "`user/repo` or just `repo` (latter will get the user from the "\ "global git config))") parser.add_option("-w", "--web", "--webbrowser", action="store_true", dest="webbrowser", default=False, help="show issue(s) GitHub page "\ "in web browser (only for list and show commands) [default: False]") parser.add_option("-V", "--version", action="store_true", dest="show_version", default=False, help="show program's version number and exit") class CustomValues: pass (options, args) = parser.parse_args(values=CustomValues) kwargs = dict([(k, v) for k, v in options.__dict__.items() \ if not k.startswith("__")]) if kwargs.get('show_version'): print("ghi %s" % get_version('short')) sys.exit(0) if kwargs.get('state'): kwargs['state'] = {'o': 'open', 'c': 'closed', 'a': 'all'}.get( kwargs['state'], kwargs['state']) if args: cmd = args[0] try: nr = str(int(cmd)) if cmd == nr: cmd = 'show' args = (cmd, nr) except: pass else: cmd = 'list' # default command if cmd == 'search': search_term = " ".join(args[1:]) args = (args[0], search_term) # handle command aliases cmd = {'o': 'open', 'c': 'close', 'e': 'edit', 'm': 'comment', 's': 'search'}.get(cmd, cmd) if cmd == 'open' and len(args) > 1: cmd = 'reopen' if cmd == 'al' or cmd == 'rl': alias = cmd cmd = 'label' args_list = [cmd, {'a': 'add', 'r': 'remove'}[alias[0]]] args_list.extend(args[1:]) args = tuple(args_list) try: repository = kwargs.get('repo') if repository: user, repo = get_remote_info_from_option(repository) else: user, repo = get_remote_info() commands = Commands(user, repo) getattr(commands, cmd)(*args[1:], **kwargs) except AttributeError: return "error: command '%s' not implemented" % cmd except Exception, info: return "error: %s" % info
v += "." + str(tertiary) if not final: if type_num: v += " " + type_ + " " + str(type_num) else: v += " pre-" + type_ else: v += " final" versions['verbose'] = v try: return versions[form] except KeyError: raise TypeError('"%s" is not a valid form specifier.' % form) __version__ = get_version('short') ########NEW FILE######## __FILENAME__ = test_issues_cli import os import sys from nose.tools import assert_raises from github.issues import main repo = 'jsmits/github-cli-public-test' prog = 'ghi' def test_commands(): for cmd, exp in test_input: def check_command(cmd, exp):
from setuptools import setup, find_packages description = "A command-line interface to the GitHub Issues API v2." cur_dir = os.path.dirname(__file__) try: long_description = open(os.path.join(cur_dir, 'README.rst')).read() except: long_description = description # needed for importing github.version sys.path.insert(0, os.path.join(cur_dir, 'src')) from github.version import get_version setup( name="github-cli", version=get_version('short'), url='http://github-cli.readthedocs.org/', license='BSD', description=description, long_description=long_description, author='Sander Smits', author_email='*****@*****.**', packages=find_packages('src'), package_dir={'': 'src'}, install_requires=['setuptools', 'simplejson'], entry_points=""" [console_scripts] ghi = github.issues:main """, classifiers=[ 'Development Status :: 5 - Production/Stable',