vale icon indicating copy to clipboard operation
vale copied to clipboard

Feature: Support running a single rule from the command line

Open sdwheeler opened this issue 2 years ago • 4 comments

I want to be able to run a readability score from the command line without having a configuration file configured for the rule.

Consider the following setup:

Folder structure:

~/.VALE
└───styles
    ├───alex
    ├───Google
    ├───Joblint
    ├───Microsoft
    ├───PowerShell-Docs
    ├───proselint
    ├───Readability
    ├───Vocab
    │   ├───Blog
    │   ├───Docs
    │   └───Marketing
    └───write-good

The vale.ini:

StylesPath = styles
MiMinAlertLevel = suggestion
Vocab = Docs

[*.md]
BasedOnStyles = Vale, PowerShell-Docs, Microsoft, alex

The rule would have to exist in the configured style path, but it does not have to be enabled in the configuration. Vale would use the style path from the vale.ini file in the workspace or specified by the --config option.

For example:

vale -rule Readability.FleschKincaid --output=JSON myfile.md

This way you could run any installed rule, not just a Readability score.

sdwheeler avatar Feb 21 '23 22:02 sdwheeler

This is possible with the latest release:

$ vale --filter='.Name=="Readability.FleschKincaid"' --output=JSON myfile.md

jdkato avatar Feb 21 '23 23:02 jdkato

The rule would have to exist in the configured style path, but it does not have to be enabled in the configuration. Vale would use the style path from the vale.ini file in the workspace or specified by the --config option.

There's a caveat here: filters can only produce a subset of the .vale.ini configuration, so the rule does have to be enabled. It can obviously, though, then be excluded in cases that you don't want it.

jdkato avatar Feb 21 '23 23:02 jdkato

There are two issues I have:

  1. I get no readability score output - I just get empty JSON {} or ✔ 0 errors, 0 warnings and 0 suggestions in 1 file.
  2. I don't want the rules enabled in my default config. I want to run any arbitrary rule from the command line as a one-off test.

EDIT

After further testing, I get output from Readability.GunningFog, Readability.FleschReadingEase and Readability.SMOG only.

sdwheeler avatar Feb 22 '23 00:02 sdwheeler

To work around the default config issue, I created a new configuration called allrules.ini that has all rules enabled. I can use this from the command line with --filter to run any rule I want.

sdwheeler avatar Feb 22 '23 00:02 sdwheeler