File tree Expand file tree Collapse file tree 3 files changed +36
-2
lines changed
Expand file tree Collapse file tree 3 files changed +36
-2
lines changed Original file line number Diff line number Diff line change 33import argparse
44from src .arguments .search import Search
55
6- version = "0.1"
6+
7+ version = "0.1.0"
78
89parser = argparse .ArgumentParser ()
910parser .add_argument ("-st" ,
Original file line number Diff line number Diff line change 77from .error import SearchError
88from .utility import Utility
99from .save import SaveSearchResults
10+ from .update import UpdateApplication
1011
11-
12+ version = "0.1.0"
1213class Prompt ():
1314 def __init__ (self , message ):
1415 self .message = message
@@ -39,6 +40,8 @@ def search_args(self):
3940 webbrowser .open (f"{ url } ?title={ self .arguments .new } " )
4041 else :
4142 webbrowser .open (url )
43+ elif self .arguments .update :
44+ update = UpdateApplication (version )
4245
4346 def search_for_results (self , save = False ):
4447 queries = ["What do you want to search" , "Tags" ]
Original file line number Diff line number Diff line change 1+ import requests as requests
2+ from termcolor import colored
3+ import sys as sys
4+
5+ from .error import SearchError
6+
7+ class UpdateApplication (object ):
8+ def __init__ (self , current_version ):
9+ self .current_version = current_version
10+ self .release_api_url = "https://api.github.com/repos/IndianOpenSourceFoundation/dynamic-cli/releases/latest"
11+
12+ self .check_for_updates ()
13+
14+ def check_for_updates (self ):
15+ try :
16+ data = requests .get (self .release_api_url )
17+ data = data .json ()
18+
19+ if 'message' in data :
20+ if data ['message' ] == "Not Found" :
21+ print (colored ("The application do not have any release" , "yellow" ))
22+ return None
23+
24+ if data .tag_name == self .current_version :
25+ print (colored ("Yeah! You have the latest version" , "green" ))
26+ else :
27+ print (colored (f"New release found - { data .tag_name } " , "red" ))
28+
29+ except Exception as exception :
30+ exception = SearchError (str (exception ), "Try later" )
You can’t perform that action at this time.
0 commit comments