Skip to content

Releases: rednafi/link-patrol

0.6

03 Feb 05:01
Compare
Choose a tag to compare

Add support for retries with a max ceiling.

link-patrol -f examples/sample_1.md -t 2s --max-retries 3 --max-backoff 4s 
Filepath: examples/sample_1.md

- Location   : https://example.com
  Status Code: 200
  OK         : true
  Message    : OK
  Attempt    : 1

- Location   : https://gen.xyz/
  Status Code: 200
  OK         : true
  Message    : OK
  Attempt    : 1

- Location   : https://reference.com
  Status Code: 403
  OK         : false
  Message    : Forbidden
  Attempt    : 3

2024/02/03 06:00:49 one or more URLs have error status codes
exit status 1

v0.5

01 Feb 20:24
Compare
Choose a tag to compare
  • Tidy up the output.
  • Adds a new OK attribute to signal link status
$ link-patrol -f examples/sample_1.md -t 5s           

Filepath: examples/sample_1.md

- Location   : https://example.com
  Status Code: 200
  OK         : true
  Message    : OK

- Location   : https://reference.com
  Status Code: 403
  OK         : false
  Message    : Forbidden

2024/02/01 21:23:40 one or more URLs have error status codes
exit status 1

v0.4

29 Jan 23:06
Compare
Choose a tag to compare
  • Adds a new --json/-j flag to print the link status as json.

Take it for a spin:

link-patrol -f <filename.md> -j | jq
{
  "location": "https://example.com",
  "statusCode": 200,
  "errMsg": ""
}
{
  "location": "https://gen.xyz/",
  "statusCode": 200,
  "errMsg": ""
}
{
  "location": "https://reference.com",
  "statusCode": 403,
  "errMsg": ""
}
2024/01/30 00:05:37 one or more URLs have error status codes
exit status 1

v0.3

20 Jan 20:11
Compare
Choose a tag to compare
  • Better test coverage.
  • Minor bug fixes.
  • No changes in functionalities.

v0.2

20 Jan 04:05
Compare
Choose a tag to compare
  • Make it brew installable
  • More test coverage
  • Fix concurrency bug

v0.1

20 Jan 03:08
Compare
Choose a tag to compare

Link Patrol

Installation

  • On MacOS, brew install:
brew tap rednafi/link-patrol https://github.com/rednafi/link-patrol \
   && brew install link-patrol
  • Or elsewhere, go install:
go install github.com/rednafi/link-patrol/cmd/link-patrol

Quickstart

Usage

link-patrol -h
NAME:
   Link patrol - detect dead links in markdown files

USAGE:
   link-patrol [global options] command [command options]

VERSION:
   sentinel

AUTHOR:
   Redowan Delowar

COMMANDS:
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --filepath value, -f value  path to the markdown file
   --timeout value, -t value   timeout for each HTTP request (default: 5s)
   --error-ok, -e              always exit with code 0 (default: false)
   --help, -h                  show help
   --version, -v               print the version

List URL status

Here's the content of a sample markdown file:

This is an [embedded](https://example.com) URL.

This is a [reference style] URL.

This is a footnote[^1] URL.

[reference style]: https://reference.com
[^1]: https://gen.xyz/

Run the following command to list thr URL statuses with a 2 second timeout for each request:

link-patrol -f examples/sample_1.md -t 2s

By default it'll exit with a non-zero code if any of URLs is invalid or unreachable. Here's
how the output looks:

Link patrol
===========

Filepath: examples/sample_1.md

- URL        : https://reference.com
  Status Code: 403
  Error      : -

- URL        : https://example.com
  Status Code: 200
  Error      : -

- URL        : https://gen.xyz/
  Status Code: 200
  Error      : -

2024/01/20 03:41:55 Some URLs are invalid or unreachable
exit status 1

Ignore Errors

Set the -e / --error-ok flag to force the CLI to always exit with code 0.

go run cmd/link-patrol/main.go -f examples/sample_1.md --error-ok

v0.1-alpha

20 Jan 02:51
Compare
Choose a tag to compare
  • The CLI is in a working state
  • Test coverage could be better