From 37e3b437c037165712cccdd0889f3ea1b9834775 Mon Sep 17 00:00:00 2001 From: leugimkm Date: Tue, 8 Feb 2022 19:14:52 -0500 Subject: [PATCH] added new functionality --- codeseeker/__main__.py | 4 +++- codeseeker/base.py | 5 +++++ codeseeker/seeker.py | 22 ++++++++++++++++++++++ setup.py | 2 +- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/codeseeker/__main__.py b/codeseeker/__main__.py index 6620597..d4593c1 100644 --- a/codeseeker/__main__.py +++ b/codeseeker/__main__.py @@ -22,7 +22,7 @@ https://leugimkm.github.io/codeseeker/ """ from .base import parse_args -from .seeker import Seeker, open_url, to_txt +from .seeker import Seeker, open_url, to_txt, show_links from .utils import show @@ -48,6 +48,8 @@ def main(): open_url(seeker, data) if args.txt: to_txt(seeker, data) + if args.links: + show_links(seeker, data) if __name__ == "__main__": diff --git a/codeseeker/base.py b/codeseeker/base.py index 32e0027..7e125c1 100644 --- a/codeseeker/base.py +++ b/codeseeker/base.py @@ -43,4 +43,9 @@ def parse_args(): action="store", help="Sets the language to search.", ) + parser.add_argument( + "--links", + action="store_true", + help="Show the links of the results.", + ) return parser.parse_args() diff --git a/codeseeker/seeker.py b/codeseeker/seeker.py index 2266f89..cd83fac 100644 --- a/codeseeker/seeker.py +++ b/codeseeker/seeker.py @@ -136,3 +136,25 @@ def to_txt( f.write("\n") except Exception as e: print(e) + + +def show_links( + seeker: Seeker, + data: List[Dict[str, str]], +) -> None: + """Prints the results in the terminal. + + Args: + seeker (Seeker): Seeker object. + data (List[Dict[str, str]]: Data received from the search. + + Raises: + ValidationException: If the data is empty. + """ + try: + validate_data_links(data) + print("\nShowing results...") + for link in data: + print(seeker.q.link.format(seeker.q.repo, link[seeker.q.tag])) + except Exception as e: + print(e) diff --git a/setup.py b/setup.py index 0af8d0f..3b1735c 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ setup( name="codeseeker", - version="0.0.6", + version="0.0.8", url="https://github.com/leugimkm/codeseeker", license="MIT", author="leugimkm",