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

Replace --rootdir (-r) with --source-dir (-S) #59

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions codebasin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import logging
import os
import sys
import warnings

from codebasin import config, finder, report, util
from codebasin.walkers.platform_mapper import PlatformMapper
Expand Down Expand Up @@ -47,10 +48,18 @@ def main():
"--rootdir",
dest="rootdir",
metavar="DIR",
default=os.getcwd(),
type=str,
default=None,
help="Set working root directory (default .)",
)
parser.add_argument(
"-S",
"--source-dir",
metavar="<path>",
dest="source_dir",
default=None,
help="Set path to source directory. "
+ "The default is the current directory.",
)
parser.add_argument(
"-c",
"--config",
Expand Down Expand Up @@ -131,7 +140,23 @@ def main():
logging.getLogger("codebasin").setLevel(
max(1, logging.WARNING - 10 * (args.verbose - args.quiet)),
)
rootdir = os.path.realpath(args.rootdir)

# Determine the root directory based on the -S and -r flags.
rootpath = None
if args.source_dir and args.rootdir:
raise RuntimeError(
"Cannot specify both --source-dir (-S) and --rootdir (-r).",
)
if not args.source_dir and not args.rootdir:
rootpath = os.getcwd()
elif args.source_dir:
rootpath = args.source_dir
elif args.rootdir:
warnings.warn(
"--rootdir (-r) is deprecated. Use --source-dir (-S) instead.",
)
rootpath = args.rootdir
rootdir = os.path.realpath(rootpath)

# Process the -p flag first to infer wider context.
filtered_platforms = []
Expand Down
Loading