Skip to content
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
22 changes: 22 additions & 0 deletions slothy/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ def main():
help="""The label or line at which the to code to optimize ends
This is mutually exclusive with -l/--loop.""",
)
parser.add_argument(
"--se",
default=[],
action="append",
nargs="*",
metavar="START,END",
help="""Specify start,end label pairs. Can be provided multiple times.
Mutually exclusive with -l/--loop, -s/--start, and -e/--end.""",
)
parser.add_argument(
"-r",
"--rename-function",
Expand Down Expand Up @@ -163,6 +172,11 @@ def main():

args = parser.parse_args()

if args.se and (args.loop or args.start or args.end):
raise CmdLineException(
"--se cannot be used together with -l/--loop, -s/--start, or -e/--end"
)

handlers = []

h_err = logging.StreamHandler(sys.stderr)
Expand Down Expand Up @@ -381,6 +395,14 @@ def check_list_of_fixed_len_list(lst):
if len(args.loop) > 0:
for lll in args.loop:
slothy.optimize_loop(lll)
elif args.se:
for pair in args.se:
parts = pair.split(",", 1)
if len(parts) != 2:
raise CmdLineException(
f"Invalid --se pair '{pair}', expected start,end"
)
slothy.optimize(start=parts[0], end=parts[1])
else:
slothy.optimize(start=args.start, end=args.end)

Expand Down
Loading