Skip to content

Commit 29b9f31

Browse files
committed
Implemented the feature
1 parent 3c6bc85 commit 29b9f31

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import argparse
44
from src.arguments.search import Search
55

6-
version = "0.1"
6+
7+
version = "0.1.0"
78

89
parser = argparse.ArgumentParser()
910
parser.add_argument("-st",

src/arguments/search.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
from .error import SearchError
88
from .utility import Utility
99
from .save import SaveSearchResults
10+
from .update import UpdateApplication
1011

11-
12+
version = "0.1.0"
1213
class 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"]

src/arguments/update.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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")

0 commit comments

Comments
 (0)