Skip to content

Commit

Permalink
Merge pull request #59 from Pennycook/source-dir
Browse files Browse the repository at this point in the history
Replace --rootdir (-r) with --source-dir (-S)
  • Loading branch information
Pennycook committed Feb 26, 2024
2 parents 0ebef0f + c4c2e6d commit 90a6325
Showing 1 changed file with 28 additions and 3 deletions.
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

0 comments on commit 90a6325

Please sign in to comment.