Glutexo / onigumo

Parallel web scraping framework
MIT License
3 stars 1 forks source link

Implement switch -h, --help to CLI #238

Open nappex opened 1 month ago

nappex commented 1 month ago

Fix #205

nappex commented 1 month ago

Tests? 🤔

thanks for reminding 😮‍💨

Glutexo commented 3 weeks ago

My observation of onigumo downloader -h not printing the help message is not a matter of this pull request. It is a bug in the code preventing switches from being parsed if a component is provided. onigumo downloader --anything would behave identically.

The question is whether to add a test case for the combination of the help switch and the component. Because of the existing bug, the test would fail and essentially make this pull request blocked. We can keep this test for the fix and by that let this pull request go through.

Glutexo commented 3 weeks ago

In my previous comment, I was wrong! 😮 It’s only the -h/--help switch that is ignored. An invalid switch like -x or --invalid still causes a help message to be printed.

$ ./onigumo downloader -h
$ ./onigumo downloader -x
Usage: onigumo [OPTION]... [COMPONENT]

Simple program that retrieves HTTP web content as structured data.

COMPONENT   Onigumo component to run, available: downloader

OPTIONS:
-h, --help      print this help
-C, --working-dir <dir> Change working dir to <dir> before running
Glutexo commented 2 weeks ago

To make it clearer:

Glutexo commented 2 weeks ago

I found the reason, why the behavior changed:

This pull request then does introduce the bug in the sense that in didn’t exist because there was no help option. At the same time, it only reveals an existing issues of unscalable pattern matching of the OptionParser.parse/2 output.

This can be still resolved tactically by using my code suggestion still being purely based on pattern-matching, probably in a separate pull request unblocking this one. The strategic solution is however to replace the pattern matching by something scalable.