Created
November 14, 2015 12:29
-
-
Save openrijal/cbaba6e12c9c864690fe to your computer and use it in GitHub Desktop.
gradle please commandline utility to copy library name to clipboard
This file contains hidden or 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
try: | |
# For Python 3.0 and later | |
from urllib.request import urlopen | |
except ImportError: | |
# Fall back to Python 2's urllib2 | |
from urllib2 import urlopen | |
import json, argparse, os, sys, pyperclip | |
def get(lib): | |
_url = 'http://gradleplease.appspot.com/search?q='+lib | |
print("Looking at: " + _url) | |
response = urlopen(_url) | |
res_json = json.loads(str(response.read()).strip()[17:-2])['response']['docs'][0] | |
_id = res_json['id'] | |
_ver = res_json['latestVersion'] | |
clip = "compile " + "'" +_id + '-' + _ver + "'" | |
pyperclip.copy(clip) | |
print("Try to Paste somewhere") | |
parser=argparse.ArgumentParser() | |
parser.add_argument("-l", help="name of the gradleplease library", type=str) | |
parser.add_argument("-p", help="name of the android project", type=str) | |
args = parser.parse_args() | |
if not args.l: | |
print ("Please enter the name of the library.") | |
print (parser.print_help()) | |
sys.exit() | |
if args.l: | |
get(args.l) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment