print error message to stderr and specify defaults of url
This commit is contained in:
eggplants 2022-02-05 05:55:04 +09:00
parent 5f3cd28046
commit fcab19a40a
No known key found for this signature in database
GPG Key ID: E84F494AD6539CE2

View File

@ -218,7 +218,6 @@ def save_urls_on_file(url_gen: Generator[str, None, None]) -> None:
+ "will be printed.", + "will be printed.",
) )
def main( # pylint: disable=no-value-for-parameter def main( # pylint: disable=no-value-for-parameter
url: Optional[str],
user_agent: str, user_agent: str,
version: bool, version: bool,
show_license: bool, show_license: bool,
@ -226,25 +225,26 @@ def main( # pylint: disable=no-value-for-parameter
oldest: bool, oldest: bool,
json: bool, json: bool,
near: bool, near: bool,
year: Optional[int],
month: Optional[int],
day: Optional[int],
hour: Optional[int],
minute: Optional[int],
save: bool, save: bool,
headers: bool, headers: bool,
known_urls: bool, known_urls: bool,
subdomain: bool, subdomain: bool,
file: bool, file: bool,
cdx: bool, cdx: bool,
start_timestamp: Optional[str],
end_timestamp: Optional[str],
cdx_filter: List[str], cdx_filter: List[str],
match_type: Optional[str],
gzip: Optional[str],
collapse: List[str], collapse: List[str],
limit: Optional[str],
cdx_print: List[str], cdx_print: List[str],
url: Optional[str] = None,
year: Optional[int] = None,
month: Optional[int] = None,
day: Optional[int] = None,
hour: Optional[int] = None,
minute: Optional[int] = None,
start_timestamp: Optional[str] = None,
end_timestamp: Optional[str] = None,
match_type: Optional[str] = None,
gzip: Optional[str] = None,
limit: Optional[str] = None,
) -> None: ) -> None:
"""\b """\b
_ _ _ _
@ -276,7 +276,7 @@ def main( # pylint: disable=no-value-for-parameter
).text ).text
) )
elif url is None: elif url is None:
click.echo("No URL detected. Please provide an URL.") click.echo("No URL detected. Please provide an URL.", err=True)
elif ( elif (
not version not version
and not oldest and not oldest
@ -288,7 +288,8 @@ def main( # pylint: disable=no-value-for-parameter
): ):
click.echo( click.echo(
"Only URL passed, but did not specify what to do with the URL. " "Only URL passed, but did not specify what to do with the URL. "
"Use --help flag for help using waybackpy." "Use --help flag for help using waybackpy.",
err=True,
) )
elif oldest: elif oldest:
availability_api = WaybackMachineAvailabilityAPI(url, user_agent=user_agent) availability_api = WaybackMachineAvailabilityAPI(url, user_agent=user_agent)
@ -383,4 +384,4 @@ def main( # pylint: disable=no-value-for-parameter
if __name__ == "__main__": if __name__ == "__main__":
main() main() # pylint: disable=no-value-for-parameter