linkChek : for your URL verifying needs!
So our first OSD600 assignment, make CLI program that checks for the status of URLs inside a file, indicating whether they functional or dead links.
Yeah I got lazy and opted for wordart so don't mind the logo (I think it's pretty slick though) And yes I know the name's a bit uninspiring to say the least (again I came up with it on the fly and think it's pretty good) but I was more concerned with making the program itself.
I present to you linkChek. A CLI tool that parses text from a file (and webpages as well!) and HTTP requests all the URLs encapsulated in it for its responses. From there it indicates whether they are [GOOD] or [BAD] links, or just [UNKNOWN]
Yeah I got lazy and opted for wordart so don't mind the logo (I think it's pretty slick though) And yes I know the name's a bit uninspiring to say the least (again I came up with it on the fly and think it's pretty good) but I was more concerned with making the program itself.
At first, having to write the program all by myself was pretty intimidating, I slacked off too much during the summer and my brain needed a refresher for writing code. Luckily, the Slack page was filled with helpful information, and there were quite a number of my peers that were writing in JavaScript, which I was planning to write the program in. So I took some of the resources that were shared, (articles on how to write a CLI program, useful npm modules, etc.) and came up with linkChek!
I went with JavaScript because I didn't want to have the addition of learning a new language (yet! Since we were given a timeframe to complete this assignment) along with writing this program from scratch. But also as an opportunity to refine my web dev skills.
I used this article
as a basis for my code and built upon that. Implementing 2 modules, yargs to process arguments for the program, and chalk to color the output according to their results. After that I used node_fetch to handle the requests to the links and obtain their responses.
I kept my program logic fairly simple and tried to write as little code as possible, partly because of my limited knowledge, but also to just build a program that does what the assignment asks, which is actually fairly simple.
- Read the file (or webpage html) as text
- Parse the URLs found into an array
- Fetch their requests one by one
- Output the results
And so there it is! linkChek version 0.0.1 [https://github.com/joelazwar/linkChek]
If you're interested in trying it
npm install https://github.com/joelazwar/linkChek
My GitHub page [https://github.com/joelazwar]
Thanks for reading :)
Comments
Post a Comment