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 returning200
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
Option | Description | Default value | Environment variable name |
---|---|---|---|
inspector.requestTimeout | HTTP request timeout | 30s | LINKS_INSPECTOR_REQUESTTIMEOUT |
inspector.doNotFollowRedirects | Do not follow redirects | false | LINKS_INSPECTOR_DONOTFOLLOWREDIRECTS |
inspector.logExternalLinks | Log external links. Links with other hostname are considered to be external | false | LINKS_INSPECTOR_LOGEXTERNALLINKS |
inspector.skipStatusCodes | Do not output results for links with the specified status codes | empty list | LINKS_INSPECTOR_SKIPSTATUSCODES |
inspector.retryAttempts | Number of retry attempts for failed requests | 3 | LINKS_INSPECTOR_RETRYATTEMPTS |
inspector.retryDelay | Delay between retry attempts | 2ms | LINKS_INSPECTOR_RETRYDELAY |
printer.sortOutput | Sort output by link URL | false | LINKS_PRINTER_SORTOUTPUT |
printer.displayOccurrences | Display number of occurrences for each link | false | LINKS_PRINTER_DISPLAYOCCURRENCES |
printer.skipOK | Do not output results for links returning 200 status code | false | LINKS_PRINTER_SKIPOK |
printer.outputFormat | Results output format. Supported formats: stdout , html , csv | stdout | LINKS_PRINTER_OUTPUTFORMAT |
printer.doNotOpenFileReport | Do not open file report in the default browser | false | LINKS_PRINTER_DONOTOPENFILEREPORT |