Skip to main content

Configuration

Default Configuration

With the default configuration, the tool will perform a quick inspection of the internal links on the specified host and output unsorted and non-aggregated results to the console on-the-fly. HTTP requests are made with a timeout of 30 seconds, and the tool will retry failed requests up to 3 times with a 2ms delay between attempts.

The full default configuration is as follows:

inspector:
requestTimeout: 30s
doNotFollowRedirects: false
logExternalLinks: false
skipStatusCodes: []
retryAttempts: 3
retryDelay: 2ms
printer:
sortOutput: false
displayOccurrences: false
skipOK: false
outputFormat: stdout
doNotOpenFileReport: false

Command Line Flags

You can set two configuration options values using command line flags:

  • printer.skipOK - do not output results for links returning 200 status codes:
links inspect --host=example.com --skipOK
  • printer.outputFormat - result output format. Supported formats: stdout, html, csv, for example:
links inspect --host=example.com --out=html

or

links inspect --host=example.com -o csv

Configuration File

The links tool supports configuration via a YAML file. You can provide a customized configuration file using the --config option:

links inspect --host=example.com --config /path/to/config.yaml

In a configuration file, you may specify only the settings you want to override. The rest will be taken from the default configuration.

Configuration file example:

inspector:
requestTimeout: 60s
skipStatusCodes:
- 200
- 301
- 302
retryAttempts: 5
retryDelay: 10ms
printer:
sortOutput: true
displayOccurrences: true
doNotOpenFileReport: true

Configuration file has one more usage, it is used to persist the configuration. See the config command section below for more details.

config Command

The config command allows you to view and modify the configuration of the links tool. It provides options to display the current configuration, set new values, and save them to a file.

View Current Configuration

To view the current configuration, use the config show command:

links config show

This command will display:

  • the path to the configuration file (if any) used by the tool,
  • the current configuration settings.

You can specify the configuration output format using the --out or -o option. Supported formats are yaml (default) and json. For example, to display the configuration in JSON format, run:

links config show -o json

Set Configuration

To set a configuration option, use the config set command followed by the option name and value. For example, to set the printer.skipOK option to true, run:

links config set printer.skipOK true

This command will update the configuration file with the new value. If the file does not exist, it will be created. If not specified, the default configuration file location will be used. See the next section for more details.

File Default Location

The configuration file's default location is different on each operating system.

On MacOS, the default location is $HOME/Library/Application Support/com.yaroslavgrebnov.links/config.yaml.

On Unix systems, it is $XDG_CONFIG_HOME/com.yaroslavgrebnov.links/config.yaml if $XDG_CONFIG_HOME is non-empty, else $HOME/.config/com.yaroslavgrebnov.links/config.yaml.

On Windows, it is %APPDATA%\com.yaroslavgrebnov.links\config.yaml.

The exact path is displayed on the first line of links config show command output.

Environment Variables

You can set configuration options values using environment variables. The environment variable name is a combination of the command line option name and the LINKS_ prefix. For example, printer skipOK setting can be configured using environment variable LINKS_PRINTER_SKIPOK:

LINKS_PRINTER_SKIPOK=true links inspect --host=example.com

Configuration Options List

OptionDescriptionDefault valueEnvironment variable name
inspector.requestTimeoutHTTP request timeout30sLINKS_INSPECTOR_REQUESTTIMEOUT
inspector.doNotFollowRedirectsDo not follow redirectsfalseLINKS_INSPECTOR_DONOTFOLLOWREDIRECTS
inspector.logExternalLinksLog external links. Links with other hostname are considered to be externalfalseLINKS_INSPECTOR_LOGEXTERNALLINKS
inspector.skipStatusCodesDo not output results for links with the specified status codesempty listLINKS_INSPECTOR_SKIPSTATUSCODES
inspector.retryAttemptsNumber of retry attempts for failed requests3LINKS_INSPECTOR_RETRYATTEMPTS
inspector.retryDelayDelay between retry attempts2msLINKS_INSPECTOR_RETRYDELAY
printer.sortOutputSort output by link URLfalseLINKS_PRINTER_SORTOUTPUT
printer.displayOccurrencesDisplay number of occurrences for each linkfalseLINKS_PRINTER_DISPLAYOCCURRENCES
printer.skipOKDo not output results for links returning 200 status codefalseLINKS_PRINTER_SKIPOK
printer.outputFormatResults output format. Supported formats: stdout, html, csvstdoutLINKS_PRINTER_OUTPUTFORMAT
printer.doNotOpenFileReportDo not open file report in the default browserfalseLINKS_PRINTER_DONOTOPENFILEREPORT