basename(argv[0]) instead of argv[0] in usage str
This commit is contained in:
parent
c71be83f43
commit
c7f6cff15a
@ -1,6 +1,7 @@
|
|||||||
"""Download pictures (or videos) along with their captions and other metadata from Instagram."""
|
"""Download pictures (or videos) along with their captions and other metadata from Instagram."""
|
||||||
|
|
||||||
import ast
|
import ast
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
from argparse import ArgumentParser, SUPPRESS
|
from argparse import ArgumentParser, SUPPRESS
|
||||||
from typing import Callable, List, Optional
|
from typing import Callable, List, Optional
|
||||||
@ -11,12 +12,16 @@ from .instaloader import Instaloader, Tristate, get_default_session_filename
|
|||||||
from .instaloadercontext import default_user_agent
|
from .instaloadercontext import default_user_agent
|
||||||
from .structures import Post
|
from .structures import Post
|
||||||
|
|
||||||
# NOTE: duplicated in README.rst and docs/index.rst
|
|
||||||
USAGE_STRING = """
|
def usage_string():
|
||||||
|
# NOTE: duplicated in README.rst and docs/index.rst
|
||||||
|
argv0 = os.path.basename(sys.argv[0])
|
||||||
|
argv0 = "instaloader" if argv0 == "__main__.py" else argv0
|
||||||
|
return """
|
||||||
{0} [--comments] [--geotags] [--stories]
|
{0} [--comments] [--geotags] [--stories]
|
||||||
{2:{1}} [--login YOUR-USERNAME] [--fast-update]
|
{2:{1}} [--login YOUR-USERNAME] [--fast-update]
|
||||||
{2:{1}} profile | "#hashtag" | :stories | :feed | :saved
|
{2:{1}} profile | "#hashtag" | :stories | :feed | :saved
|
||||||
{0} --help""".format(sys.argv[0], len(sys.argv[0]), '')
|
{0} --help""".format(argv0, len(argv0), '')
|
||||||
|
|
||||||
|
|
||||||
def filterstr_to_filterfunc(filter_str: str, logged_in: bool) -> Callable[['Post'], bool]:
|
def filterstr_to_filterfunc(filter_str: str, logged_in: bool) -> Callable[['Post'], bool]:
|
||||||
@ -131,11 +136,11 @@ def _main(instaloader: Instaloader, targetlist: List[str],
|
|||||||
instaloader.context.log("No targets were specified, thus nothing has been downloaded.")
|
instaloader.context.log("No targets were specified, thus nothing has been downloaded.")
|
||||||
else:
|
else:
|
||||||
# Instloader did not do anything
|
# Instloader did not do anything
|
||||||
instaloader.context.log("usage:" + USAGE_STRING)
|
instaloader.context.log("usage:" + usage_string())
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = ArgumentParser(description=__doc__, add_help=False, usage=USAGE_STRING,
|
parser = ArgumentParser(description=__doc__, add_help=False, usage=usage_string(),
|
||||||
epilog="Report issues at https://github.com/instaloader/instaloader/issues. "
|
epilog="Report issues at https://github.com/instaloader/instaloader/issues. "
|
||||||
"The complete documentation can be found at "
|
"The complete documentation can be found at "
|
||||||
"https://instaloader.github.io/.")
|
"https://instaloader.github.io/.")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user