diff --git a/doc/tools/qvm-appmenus.rst b/doc/tools/qvm-appmenus.rst index 4191e12..7bbbfec 100644 --- a/doc/tools/qvm-appmenus.rst +++ b/doc/tools/qvm-appmenus.rst @@ -48,12 +48,12 @@ OPTIONS --set-default-whitelist PATH 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. ---get-available [EXPERIMENTAL] [REQUIRES --i-understand-format-is-unstable] - List all available applications for the VM. The current format is UNSTABLE. +--get-available + List all available applications for the VM. The applications are listed as hyphen-separated pairs consisting of file name and application name. --file-field FIELDNAME - .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. + .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. AUTHORS ======= diff --git a/qubesappmenus/__init__.py b/qubesappmenus/__init__.py index 19d6d5f..15427a6 100644 --- a/qubesappmenus/__init__.py +++ b/qubesappmenus/__init__.py @@ -761,7 +761,7 @@ def appmenus_update(self, vm, force=False): parser.add_argument( '--i-understand-format-is-unstable', dest='fool', action='store_true', - help='required pledge for --get-available') + help='deprecated no-op for backward compatibility') parser.add_argument( '--file-field', action='append', dest='fields', help='File field to append to output for --get-available; can be used' @@ -795,6 +795,9 @@ def retrieve_list(path): def main(args=None, app=None): """main function for qvm-appmenus tool""" args = parser.parse_args(args=args, app=app) + if args.fool: + print('Warning: --i-understand-format-is-unstable is deprecated ' + 'and has no effect.', file=sys.stderr) if not args.all_domains and not args.domains: parser.error("one of the arguments --all VMNAME is required") appmenus = Appmenus() @@ -852,10 +855,6 @@ def main(args=None, app=None): if args.update: appmenus.appmenus_update(vm, force=args.force) if args.get_available: - if not args.fool: - parser.error( - 'this requires --i-understand-format-is-unstable ' - 'and a sacrifice of one cute kitten') if not args.fields: sys.stdout.write(''.join('{} - {}\n'.format(*available) for available in diff --git a/qubesappmenus/tests.py b/qubesappmenus/tests.py index 4962455..0430dd0 100644 --- a/qubesappmenus/tests.py +++ b/qubesappmenus/tests.py @@ -726,6 +726,23 @@ def test_131_set_get_default_whitelist(self, mock_subprocess): self.ext.set_default_whitelist(tpl, whitelist) self.assertEqual(whitelist, self.ext.get_default_whitelist(tpl)) + @unittest.mock.patch('qubesappmenus.Appmenus') + def test_132_get_available_does_not_require_unstable_flag( + self, appmenus_cls): + vm = TestVM('test-inst-vm', klass='AppVM', + label=self.app.labels[1]) + self.app.domains[vm.name] = vm + appmenus_cls.return_value.get_available.return_value = [ + ('xterm.desktop', 'XTerm')] + + with unittest.mock.patch('sys.stdout', new_callable=io.StringIO) \ + as stdout: + qubesappmenus.main( + ['--force-root', '--get-available', vm.name], app=self.app) + + appmenus_cls.return_value.get_available.assert_called_once_with(vm) + self.assertEqual(stdout.getvalue(), 'xterm.desktop - XTerm\n') + def list_tests(): return (TC_00_Appmenus,)