mirror of
https://github.com/bndr/pipreqs.git
synced 2025-06-06 03:25:21 +00:00
Support optional <path> argument
This change makes the <path> argument optional, defaulting to the current working directory if omitted. --- Ideally, this would have been accomplished via docopt, but optional positional arguments with defaults are not supported at the moment [1, 2]. [1] https://github.com/docopt/docopt/issues/214 [2] https://github.com/docopt/docopt/issues/329
This commit is contained in:
parent
755e20196a
commit
c80d06593d
@ -3,7 +3,12 @@
|
|||||||
"""pipreqs - Generate pip requirements.txt file based on imports
|
"""pipreqs - Generate pip requirements.txt file based on imports
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
pipreqs [options] <path>
|
pipreqs [options] [<path>]
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
<path> The path to the directory containing the application
|
||||||
|
files for which a requirements file should be
|
||||||
|
generated (defaults to the current working directory).
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--use-local Use ONLY local package info instead of querying PyPI
|
--use-local Use ONLY local package info instead of querying PyPI
|
||||||
@ -335,11 +340,14 @@ def init(args):
|
|||||||
encoding = args.get('--encoding')
|
encoding = args.get('--encoding')
|
||||||
extra_ignore_dirs = args.get('--ignore')
|
extra_ignore_dirs = args.get('--ignore')
|
||||||
follow_links = not args.get('--no-follow-links')
|
follow_links = not args.get('--no-follow-links')
|
||||||
|
input_path = args['<path>']
|
||||||
|
if input_path is None:
|
||||||
|
input_path = os.path.abspath(os.curdir)
|
||||||
|
|
||||||
if extra_ignore_dirs:
|
if extra_ignore_dirs:
|
||||||
extra_ignore_dirs = extra_ignore_dirs.split(',')
|
extra_ignore_dirs = extra_ignore_dirs.split(',')
|
||||||
|
|
||||||
candidates = get_all_imports(args['<path>'],
|
candidates = get_all_imports(input_path,
|
||||||
encoding=encoding,
|
encoding=encoding,
|
||||||
extra_ignore_dirs=extra_ignore_dirs,
|
extra_ignore_dirs=extra_ignore_dirs,
|
||||||
follow_links=follow_links)
|
follow_links=follow_links)
|
||||||
@ -368,7 +376,7 @@ def init(args):
|
|||||||
pypi_server=pypi_server)
|
pypi_server=pypi_server)
|
||||||
|
|
||||||
path = (args["--savepath"] if args["--savepath"] else
|
path = (args["--savepath"] if args["--savepath"] else
|
||||||
os.path.join(args['<path>'], "requirements.txt"))
|
os.path.join(input_path, "requirements.txt"))
|
||||||
|
|
||||||
if args["--diff"]:
|
if args["--diff"]:
|
||||||
diff(args["--diff"], imports)
|
diff(args["--diff"], imports)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user