Description: This is a basic URL checker written in GO. The app allows users to pass in a file name as a command-line argument, then it would extract all valid URLs and run status check on those urls.
- Clone the repo and build the binary file locally by running
go build linkDetector.go
- Move to the folder you want the binary file to be and install it directly through
go get
go get github.com/tonyvugithub/GoURLsCheckerCLI
Notice: This will create a binary name GoURLsCheckerCLI as opposed to linkDetector in the first option.
-
Display help panel by not include any argument
./linkDetector
-
Display current version using -v or -version flag
./linkDetector -v or -version
-
Check multiple files:
//For paths that contain space, simply wrap the path in quotes ./linkDetector check -f [file-path-1] [file-path-2] ... [file-path-nth]
-
Check all files in single or multiple directories:
//For paths that contain space, simply wrap the path in quotes ./linkDetector check -d [directory-path-1] [directory-path-2] ... [directory-path-nth]
-
Allows user to pass glob pattern as argument:
Example: Uses as a standalone, The command would be applied to the current directory of the executable file./linkDetector -g *.html
Example: Uses with -d flag
//The glob pattern needs to be the last argument ./linkDetector check -d -g "Absolute\Path\To\Your\Directory" *.txt
-
Create report file by adding -r flag:
./linkDetector check -f -r [file-path]
./linkDetector check -d -r [directory-path]
-
Use custom User-Agents with the -u flag:
./linkDetector check -u [User-Agent string] -f [file-path]
an example using a Firefox User-Agent:
./linkDetector check -u "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0" -f [file-path]
-
Ignore a list of urls:
./linkDetector check -i [file-path-ignore-list] [file-path]
A valid ignore list will have a # for comments and http/https links For example:
# ignore the canadian google links https://google.ca # this link wont be ignore https://netflix.com https://www.spotify.com/
-
Check the latest 10 post of Telescope posts
./linkDetector check -t
Note: the order of flags does not matter but all flags need to follow main command and before any file path / directory path arguments