forked from drath/libratbag
tools: ratbagctl: add "name" command to return the device name
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
committed by
Peter Hutterer
parent
3fd7cd0137
commit
7c650aeeca
@@ -523,6 +523,11 @@ def func_profile_disable(r, args):
|
||||
d.commit()
|
||||
|
||||
|
||||
def func_device_name_get(r, args):
|
||||
d = find_device(r, args)
|
||||
print(d.name)
|
||||
|
||||
|
||||
################################################################################
|
||||
# these are definitions to be reused in the dict that defines our language
|
||||
|
||||
@@ -638,6 +643,12 @@ parser_def = [
|
||||
func: show_device,
|
||||
group: 'Device',
|
||||
},
|
||||
{
|
||||
of_type: command,
|
||||
name: 'name',
|
||||
help_str: 'Returns the device name',
|
||||
func: func_device_name_get,
|
||||
},
|
||||
{
|
||||
of_type: switch,
|
||||
name: 'profile',
|
||||
|
||||
@@ -116,6 +116,14 @@ class TestRatbagCtlInfo(TestRatbagCtl):
|
||||
self.launch_fail_test("info X")
|
||||
|
||||
|
||||
class TestRatbagCtlName(TestRatbagCtl):
|
||||
def test_get(self):
|
||||
r = self.launch_good_test("name test_device")
|
||||
self.assertEqual(r, 'Test device')
|
||||
self.launch_fail_test("name test_device X")
|
||||
self.launch_fail_test("name X")
|
||||
|
||||
|
||||
class TestRatbgagCtlProfile(TestRatbagCtl):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
||||
Reference in New Issue
Block a user