Closed
Description
This is similar to #40 but slightly different. I'd like to be able to pass multiple file names on the command line and check each one in sequence, e.g. markdown-link-check file1.md file2.md
The motivation for this is trying to add a hook with pre-commit (https://pre-commit.com/); this splits the full list of files to check into smaller lists, but currently only one file from each list is checked.
This would also potentially allow some optimizations; for example if a URL appears in two markdown files, you would only need to make the request once and cache the status for subsequent checks.
Activity
lorenzwalthert commentedon Dec 26, 2019
I'd like to see this feature implemented too for the very same reason. Thanks for this cool package.
waylan commentedon May 6, 2020
I would like this option as well. We run all tests on our CI server. We need a single pass/fail report for all checked files. As the tool only checks a single file at a time, we need to write our own shell script which loops through all files, keeps track of any failures, and then reports a pass/fail. It would be nice if the tool could do all of that itself. Then we could simply call the tool once and be done.
NicolasMassart commentedon Sep 25, 2020
This part is interesting and preventing calls to many similar urls is definitely a feature to add. Maybe in a separated ticket
NicolasMassart commentedon Sep 25, 2020
For the multiple files passed in a sorted manner, there's multiple things here:
Testing multiple files
This is what can be done with the
find
command for instance usingfind . -name \*.md -exec markdown-link-check {} \;
-exec
runsmarkdown-link-check
for each file (one by find output line)To achieve this with an arbitrary input, not from the
find
command you can use thexargs
shell command.Use your command, whatever the command, can be
git
orls
we don't care as soon as it returns file paths, one by line like these with a link to "https://github.com/tcort/markdown-link-check" in each:Then use:
and you will have
See https://stackoverflow.com/questions/2711001/how-to-apply-shell-command-to-each-line-of-a-command-output for subtleties on using
xargs
lorenzwalthert commentedon Sep 25, 2020
Thanks for the explanation. But for prec-commit hooks, we need a single command that takes options and a list of files. The approach with xargs does not work out of the box with that.
Also, I am not sure what exactly prevents you from just looping over the input files internally. This seems like not a great deal to implement and there is a high demand from the community.
chriselion commentedon Sep 25, 2020
We were using an
xargs
-based approach for a while for pre-commit, and later a bash loop, but I eventually switched to a small python script that makes multiple calls tomarkdown-link-check
chriselion commentedon Sep 25, 2020
Created a separate ticket. Lower priority than this one though (IMHO) #111
waylan commentedon Sep 26, 2020
While the
find
andxargs
one-liners work, they don't result in a single unified report. I need a single pass/fail for all files. For an example, see my bash script. The first few lines are unique in that they build the list of files specific to my project, but the rest should be handled internally bymarkdown-link-check
.10 remaining items