From 39b35c7e991c4864deb999a482a6abb11faf752d Mon Sep 17 00:00:00 2001 From: "Garen J. Torikian" Date: Fri, 31 Dec 2021 14:54:01 -0500 Subject: [PATCH] new cli opts --- README.md | 8 +- bin/htmlproofer | 15 ++-- spec/html-proofer/command_spec.rb | 30 ++++--- spec/html-proofer/fixtures/cache/.runner.log | 2 +- .../version_2/.internal_and_external.log | 2 +- .../version_2/.recheck_external_failure.log | 2 +- .../cache/version_2/.removed_link.log | 2 +- .../cache_log_level_error_type_file_.yml | 83 +++++++++++++++++++ 8 files changed, 121 insertions(+), 23 deletions(-) create mode 100644 spec/html-proofer/fixtures/vcr_cassettes/cache/internal_and_external_example_html_cache_timeframe_1d_cache_file_version_2/_internal_and_external_log_storage_dir_spec/html-proofer/fixtures/cache_log_level_error_type_file_.yml diff --git a/README.md b/README.md index 706fd9ce..0fd12af8 100644 --- a/README.md +++ b/README.md @@ -300,8 +300,6 @@ The `HTMLProofer` constructor takes an optional hash of additional options: | `only_4xx` | Only reports errors for links that fall within the 4xx status code range. | `false` | | `root_dir` | The absolute path to the directory serving your html-files. | "" | | `swap_urls` | A hash containing key-value pairs of `RegExp => String`. It transforms URLs that match `RegExp` into `String` via `gsub`. | `{}` | -| `typhoeus_config` | A JSON-formatted string. Parsed using `JSON.parse` and mapped on top of the default configuration values so that they can be overridden. | `{}` | - In addition, there are a few "namespaced" options. These are: @@ -337,6 +335,8 @@ The default value is: } ``` +On the CLI, you can provide the `--typhoeus` or `hydra` arguments. These are parsed using `JSON.parse` and mapped on top of the default configuration values so that they can be overridden. + #### Setting `before-request` callback You can provide a block to set some logic before an external link is checked. For example, say you want to provide an authentication token every time a GitHub URL is checked. You can do that like this: @@ -363,6 +363,8 @@ In this example, `in_processes: 3` is passed into Parallel as a configuration op Pass in `:parallel => { enable: false }` to disable parallel runs. +On the CLI, you can provide the `--parallel` argument. This is parsed using `JSON.parse` and mapped on top of the default configuration values so that they can be overridden. + ## Configuring caching Checking external URLs can slow your tests down. If you'd like to speed that up, you can enable caching for your external links. Caching simply means to skip links that are valid for a certain period of time. @@ -398,6 +400,8 @@ The cache operates on external links only. If caching is enabled, HTMLProofer writes to a log file called *tmp/.htmlproofer/cache.log*. You should probably ignore this folder in your version control system. +On the CLI, you can provide the `--timeframe` or `--storage-dir` arguments to control the cache behavior. + ### Caching with continuous integration Enable caching in your continuous integration process. It will make your builds faster. diff --git a/bin/htmlproofer b/bin/htmlproofer index 74cd3b0c..5b7e3923 100755 --- a/bin/htmlproofer +++ b/bin/htmlproofer @@ -33,12 +33,14 @@ Mercenary.program(:htmlproofer) do |p| p.option 'ignore_urls', '--ignore-urls link1,[link2,...]', Array, 'A comma-separated list of Strings or RegExps containing URLs that are safe to ignore. This affects all HTML attributes, such as `alt` tags on images.' p.option 'log_level', '--log-level ', String, 'Sets the logging level, as determined by Yell. One of `:debug`, `:info`, `:warn`, `:error`, or `:fatal`. (default: `:info`)' p.option 'only_4xx', '--only-4xx', 'Only reports errors for links that fall within the 4xx status code range' + p.option 'root_dir', '--root-dir PATH', String, 'The absolute path to the directory serving your html-files.' p.option 'storage_dir', '--storage-dir PATH', String, 'Directory where to store the cache log (default: "tmp/.htmlproofer")' - p.option 'timeframe', '--timeframe