mirror of
https://gitlab.freedesktop.org/upower/power-profiles-daemon.git
synced 2026-05-06 04:28:16 +02:00
powerprofilesctl: Throw an unrecognized arguments error on on launch-commands
This commit is contained in:
parent
8574070267
commit
acd17bd066
2 changed files with 30 additions and 1 deletions
|
|
@ -205,12 +205,19 @@ def get_parser():
|
|||
|
||||
|
||||
def main():
|
||||
args, unknown = get_parser().parse_known_args()
|
||||
parser = get_parser()
|
||||
args, unknown = parser.parse_known_args()
|
||||
# default behavior is to run list if no command is given
|
||||
if not args.command:
|
||||
args.func = _list
|
||||
if args.command == "launch":
|
||||
args.arguments += unknown
|
||||
unknown = []
|
||||
|
||||
if unknown:
|
||||
msg = argparse._("unrecognized arguments: %s")
|
||||
parser.error(msg % " ".join(unknown))
|
||||
|
||||
args.func(args)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1727,6 +1727,28 @@ class Tests(dbusmock.DBusTestCase):
|
|||
)
|
||||
self.assertEqual(tmpf.readlines(), ["--foo --bar -v arg\n"])
|
||||
|
||||
def test_unknown_action(self):
|
||||
self.create_platform_profile()
|
||||
self.start_daemon()
|
||||
self.assert_eventually(lambda: self.get_dbus_property("ActiveProfile"))
|
||||
|
||||
with self.assertRaises(subprocess.CalledProcessError):
|
||||
tool_cmd = self.powerprofilesctl_command()
|
||||
subprocess.check_output(
|
||||
tool_cmd + ["hopefully-invalid-action"], stderr=subprocess.PIPE
|
||||
)
|
||||
|
||||
def test_unknown_list_argument(self):
|
||||
self.create_platform_profile()
|
||||
self.start_daemon()
|
||||
self.assert_eventually(lambda: self.get_dbus_property("ActiveProfile"))
|
||||
|
||||
with self.assertRaises(subprocess.CalledProcessError):
|
||||
subprocess.check_output(
|
||||
self.powerprofilesctl_command() + ["list", "--invalid-argument"],
|
||||
stderr=subprocess.PIPE,
|
||||
)
|
||||
|
||||
def test_vanishing_hold(self):
|
||||
self.create_platform_profile()
|
||||
self.start_daemon()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue