Skip to content
This repository has been archived by the owner on May 17, 2019. It is now read-only.

Commit

Permalink
use args parse
Browse files Browse the repository at this point in the history
  • Loading branch information
eeue56 committed Mar 8, 2016
1 parent 5063b2d commit 241f777
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions elm_deps_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import json
import requests
import struct
import argparse

def load_all_packages(elm_version):
payload = requests.get("http://package.elm-lang.org/all-packages?elm-package-version={elm_version}".format(
Expand All @@ -23,9 +24,10 @@ def load_versions(package_name):

def load_local_packages(elm_package):
with open(elm_package) as f:
return json.load(f)
return json.load(f)['dependencies']

def top_range(field):
print(field)
only_end = field[field.index('v'):]

if '=' in only_end:
Expand Down Expand Up @@ -90,11 +92,22 @@ def print_newer_versions(local_deps, remote_deps):
print('\n'.join(upgrade_suggestions))


def main():

if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Check deps file for possible upgrades')

parser.add_argument('--elm-version', help='specify your current elm version', default='0.16')

parser.add_argument('local')
args = parser.parse_args()

local = load_local_packages(args.local)
remote = load_all_packages(args.elm_version)

if len(sys.argv) > 1:
local = load_local_packages(sys.argv[1])
remote = load_all_packages('0.16')
print_newer_versions(local['dependencies'], remote)
print_newer_versions(local, remote)



if __name__ == '__main__':
main()

0 comments on commit 241f777

Please sign in to comment.