Skip to content

Commit

Permalink
Merge pull request #8 from leugimkm/dev
Browse files Browse the repository at this point in the history
added new functionality
  • Loading branch information
leugimkm authored Feb 9, 2022
2 parents de3aab4 + 37e3b43 commit 93e361a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
4 changes: 3 additions & 1 deletion codeseeker/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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__":
Expand Down
5 changes: 5 additions & 0 deletions codeseeker/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
22 changes: 22 additions & 0 deletions codeseeker/seeker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 93e361a

Please sign in to comment.