Implemented git shell
This commit is contained in:
parent
ac327d0c44
commit
2718a2e23a
0
pubs/plugs/git/__init__.py
Normal file
0
pubs/plugs/git/__init__.py
Normal file
32
pubs/plugs/git/git.py
Normal file
32
pubs/plugs/git/git.py
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
import subprocess
|
||||||
|
from pipes import quote as shell_quote
|
||||||
|
|
||||||
|
from ...plugins import PapersPlugin
|
||||||
|
|
||||||
|
|
||||||
|
class GitPlugin(PapersPlugin):
|
||||||
|
|
||||||
|
name = 'git'
|
||||||
|
|
||||||
|
def __init__(self, conf):
|
||||||
|
self.description = "Run git commands in the pubs directory"
|
||||||
|
|
||||||
|
def update_parser(self, subparsers, conf):
|
||||||
|
git_parser = self.parser(subparsers)
|
||||||
|
git_parser.set_defaults(func=self.command)
|
||||||
|
|
||||||
|
def parser(self, parser):
|
||||||
|
self.parser = parser
|
||||||
|
p = parser.add_parser(self.name, help=self.description)
|
||||||
|
p.add_argument('arguments', nargs='*', help="look at man git")
|
||||||
|
return p
|
||||||
|
|
||||||
|
def command(self, conf, args):
|
||||||
|
"""Runs the git program in a shell"""
|
||||||
|
subprocess.call(
|
||||||
|
'pubs_git() {{\ngit -C {} $@\n}}\npubs_git {}'.format(
|
||||||
|
conf['main']['pubsdir'],
|
||||||
|
' '.join([shell_quote(a) for a in args.arguments])
|
||||||
|
), shell=True)
|
||||||
|
|
3
setup.py
3
setup.py
@ -33,7 +33,8 @@ setup(
|
|||||||
'pubs.commands',
|
'pubs.commands',
|
||||||
'pubs.templates',
|
'pubs.templates',
|
||||||
'pubs.plugs',
|
'pubs.plugs',
|
||||||
'pubs.plugs.alias'],
|
'pubs.plugs.alias',
|
||||||
|
'pubs.plugs.git'],
|
||||||
entry_points={
|
entry_points={
|
||||||
'console_scripts': [
|
'console_scripts': [
|
||||||
'pubs=pubs.pubs_cmd:execute',
|
'pubs=pubs.pubs_cmd:execute',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user