Last active
August 31, 2023 20:45
-
-
Save renegarcia/598f5d8dac1c4c462d60abe07c785463 to your computer and use it in GitHub Desktop.
A lightweight tool to clone git repositories.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from subprocess import run | |
from os.path import split | |
from cleo import Command, Application | |
import os | |
ROOT = {'github': '[email protected]', | |
'bitbucket': '[email protected]'} | |
def gitUrl(username, repository, location='github'): | |
urlTemplate = '{location}:{username}/{repository}.git' | |
location = ROOT[location] | |
return urlTemplate.format( | |
location=location, | |
username=username, | |
repository=repository) | |
def clone(username, repository, location='github'): | |
url = gitUrl(username, repository, location=location) | |
completedProcess = run(['git', 'clone', url]) | |
return completedProcess.returncode | |
class CloneCommand(Command): | |
''' | |
Clone a github repository | |
clone | |
{username : Username} | |
{repository : Repository} | |
{--l|loc=github : Possible options are github or bitbucket. Default is github} | |
''' | |
def handle(self): | |
username = self.argument('username') | |
repository = self.argument('repository') | |
location = self.option('loc') | |
if not location: | |
location = 'github' | |
return clone(username, repository, location=location) | |
application = Application() | |
application.add(CloneCommand()) | |
if __name__ == '__main__': | |
application.run() | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cleo >= 0.8.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import setuptools | |
setuptools.setup( | |
name='github.py', | |
version='0.0.1', | |
license='MIT', | |
author='Rene Garcia', | |
author_email='[email protected]', | |
description='Cloning git repos tool', | |
scripts=['src/github.py'], | |
install_requires = [ | |
'cleo >= 0.8.1']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A lightweight tool to clone git repositories.