Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behavior when specifying directory #139

Closed
mre opened this issue Feb 12, 2021 · 6 comments
Closed

Behavior when specifying directory #139

mre opened this issue Feb 12, 2021 · 6 comments
Labels
help wanted Extra attention is needed question Further information is requested
Projects

Comments

@mre
Copy link
Member

mre commented Feb 12, 2021

Open question: what should be the default behavior if a directory is given?
At the moment we throw and error and stop. Instead, the user has to use a glob pattern for recursion, e.g. **/*.md.
That doesn't seem to be very intuitive right now. See lycheeverse/lychee-action#3.

Here's my proposal:
If the user specifies a single directory, analyze all supported files (currently html/md/txt) within that directory.
This also holds if the user specifies a glob that implies a directory.

Any objections or concerns?

@mre mre added help wanted Extra attention is needed question Further information is requested labels Feb 12, 2021
@joesan
Copy link
Contributor

joesan commented Feb 22, 2021

Could we just show the usage and quit? I mean error out but hinting the user with a proper message on how to specify the glob pattern for the directory.

@mre
Copy link
Member Author

mre commented Feb 22, 2021

That would work. My main question is what a user expects when specifying a directory.
E.g. when they run lychee docs/, they probably have some standard behavior in mind. At least I would think that this is checking all known files within the docs folder, but I want to hear other people's opinion on that before making a call.

@polarathene
Copy link
Contributor

Probably makes sense for just checking files within that directory level, but not nested directories that would require a glob pattern. At least, users may be familiar with that with something like ls or .gitignore(kinda different since it'd ignore the full subtree in this case) when passing a directory?

Otherwise bailing to inform the user that they probably meant directory/* (all files in directory) or directory/** (all files in subtree) seems fine.

The fact that a user may be unsure which of those two globbing outcomes would occur may make it better to throw the error and ask the user to be a bit more specific with what they'd like.

@mre
Copy link
Member Author

mre commented Feb 27, 2021

You are right. Bailing makes sense as the behavior is ambiguous. Even worse, the link check could skip over files that the user thinks were included. Happy to accept a PR here.

@mre
Copy link
Member Author

mre commented Feb 27, 2021

(Just also want to point out that @joesan had the same idea and that I like the teamwork on this one. 😆)

@mre
Copy link
Member Author

mre commented Dec 3, 2021

If the user specifies a single directory, analyze all supported files (currently html/md/txt) within that directory.

This is supported in master now after #330 got merged. 🎉

If multiple directories are given as arguments and one cannot be read it will exit with an error message as well.

@mre mre closed this as completed Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
No open projects
v1.0
To do
Development

No branches or pull requests

3 participants