Skip to content

Commit

Permalink
Allow parsers that don’t handle commands yet
Browse files Browse the repository at this point in the history
Parsers serve two purposes:

1. They determine whether or not a command executes its arguments.
2. They determine which parts of a command’s arguments are other
   commands that get executed.

Before this change, parsers would have to do both, or else you would get
an AttributeError. Now, you can create a partial parser that can confirm
that a specific invocation doesn’t run any of its arguments but can’t
handle invocations that do run their arguments.

Specifically, this change is in preparation for adding a parser for
flatpak. flatpak has 43 built-in subcommands, some of which are able to
execute their arguments. I don’t want to bother adding a parser that
supports all 43 of those. I want to add a parser that supports a single
subcommand, and that subcommand can’t run its arguments.
  • Loading branch information
Jayman2000 authored and abathur committed Sep 20, 2023
1 parent 5b7ae0c commit 370d6f3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions resholve
Original file line number Diff line number Diff line change
Expand Up @@ -3837,6 +3837,9 @@ class RecordCommandlike(object):
return True

def handle_external_generic(self, parsed, invocation):
if not hasattr(parsed, "commands"):
return True

# TODO: shimming shells in here may be a bigger crime than
# duplicating the logic in two functions would be?
shell = invocation.firstword in INVOKABLE_SHELLS
Expand Down

0 comments on commit 370d6f3

Please sign in to comment.