MCPcopy
hub / github.com/beetbox/beets / parse_subcommand

Method parse_subcommand

beets/ui/__init__.py:746–761  ·  view source on GitHub ↗

Given the `args` left unused by a `parse_global_options`, return the invoked subcommand, the subcommand options, and the subcommand arguments.

(self, args)

Source from the content-addressed store, hash-verified

744 return options, subargs
745
746 def parse_subcommand(self, args):
747 """Given the `args` left unused by a `parse_global_options`,
748 return the invoked subcommand, the subcommand options, and the
749 subcommand arguments.
750 """
751 # Help is default command
752 if not args:
753 args = ["help"]
754
755 cmdname = args.pop(0)
756 subcommand = self._subcommand_for_name(cmdname)
757 if not subcommand:
758 raise UserError(f"unknown command '{cmdname}'")
759
760 suboptions, subargs = subcommand.parse_args(args)
761 return subcommand, suboptions, subargs
762
763
764optparse.Option.ALWAYS_TYPED_ACTIONS += ("callback",)

Callers 1

_raw_mainFunction · 0.95

Calls 3

_subcommand_for_nameMethod · 0.95
UserErrorClass · 0.90
parse_argsMethod · 0.80

Tested by

no test coverage detected