Skip to content

Commit 09e903e

Browse files
committed
qvm-appmenus: drop unstable-format pledge for get-available
--get-available no longer requires --i-understand-format-is-unstable. The flag is kept as a deprecated no-op for backward compatibility and prints a warning to stderr when used. Fixes QubesOS/qubes-issues#10595
1 parent 3667bff commit 09e903e

3 files changed

Lines changed: 23 additions & 8 deletions

File tree

doc/tools/qvm-appmenus.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ OPTIONS
4848
--set-default-whitelist PATH
4949
Set the default list of applications to be included in the menus of VMs based on this template. Should only be used for TemplateVMs .The PATH can be either a path to file containing a list of .desktop files, or a single hyphen ('-') to read from standard input.
5050

51-
--get-available [EXPERIMENTAL] [REQUIRES --i-understand-format-is-unstable]
52-
List all available applications for the VM. The current format is UNSTABLE.
51+
--get-available
52+
List all available applications for the VM.
5353
The applications are listed as hyphen-separated pairs consisting of file name and application name.
5454

5555
--file-field FIELDNAME
56-
.desktop file field to append to output for --get-available; can be used multiple times for multiple fields. This option changes output format to pipe-("|") separated. The current format is UNSTABLE.
56+
.desktop file field to append to output for --get-available; can be used multiple times for multiple fields. This option changes output format to pipe-("|") separated.
5757
5858
AUTHORS
5959
=======

qubesappmenus/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ def appmenus_update(self, vm, force=False):
761761
parser.add_argument(
762762
'--i-understand-format-is-unstable', dest='fool',
763763
action='store_true',
764-
help='required pledge for --get-available')
764+
help='deprecated no-op for backward compatibility')
765765
parser.add_argument(
766766
'--file-field', action='append', dest='fields',
767767
help='File field to append to output for --get-available; can be used'
@@ -795,6 +795,9 @@ def retrieve_list(path):
795795
def main(args=None, app=None):
796796
"""main function for qvm-appmenus tool"""
797797
args = parser.parse_args(args=args, app=app)
798+
if args.fool:
799+
print('Warning: --i-understand-format-is-unstable is deprecated '
800+
'and has no effect.', file=sys.stderr)
798801
if not args.all_domains and not args.domains:
799802
parser.error("one of the arguments --all VMNAME is required")
800803
appmenus = Appmenus()
@@ -852,10 +855,6 @@ def main(args=None, app=None):
852855
if args.update:
853856
appmenus.appmenus_update(vm, force=args.force)
854857
if args.get_available:
855-
if not args.fool:
856-
parser.error(
857-
'this requires --i-understand-format-is-unstable '
858-
'and a sacrifice of one cute kitten')
859858
if not args.fields:
860859
sys.stdout.write(''.join('{} - {}\n'.format(*available)
861860
for available in

qubesappmenus/tests.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,22 @@ def test_131_set_get_default_whitelist(self, mock_subprocess):
726726
self.ext.set_default_whitelist(tpl, whitelist)
727727
self.assertEqual(whitelist, self.ext.get_default_whitelist(tpl))
728728

729+
@unittest.mock.patch('qubesappmenus.Appmenus')
730+
def test_132_get_available_does_not_require_unstable_flag(
731+
self, appmenus_cls):
732+
vm = TestVM('test-inst-vm', klass='AppVM',
733+
label=self.app.labels[1])
734+
self.app.domains[vm.name] = vm
735+
appmenus_cls.return_value.get_available.return_value = [
736+
('xterm.desktop', 'XTerm')]
737+
738+
with unittest.mock.patch('sys.stdout', new_callable=io.StringIO) \
739+
as stdout:
740+
qubesappmenus.main(['--get-available', vm.name], app=self.app)
741+
742+
appmenus_cls.return_value.get_available.assert_called_once_with(vm)
743+
self.assertEqual(stdout.getvalue(), 'xterm.desktop - XTerm\n')
744+
729745

730746
def list_tests():
731747
return (TC_00_Appmenus,)

0 commit comments

Comments
 (0)