mirror of
				https://github.com/arcan1s/ahriman.git
				synced 2025-10-31 13:53:41 +00:00 
			
		
		
		
	add now argument to add command
This commit is contained in:
		| @ -66,7 +66,7 @@ Wrapper for managing custom repository inspired by [repo-scripts](https://github | ||||
| * Add packages by using `ahriman add {package}` command: | ||||
|  | ||||
|     ```shell | ||||
|     sudo -u ahriman ahriman -a x86_64 add yay | ||||
|     sudo -u ahriman ahriman -a x86_64 add yay --now | ||||
|     ``` | ||||
|  | ||||
| Note that initial service configuration can be done by running `ahriman setup` with specific arguments. | ||||
|  | ||||
| @ -77,6 +77,7 @@ def _set_add_parser(root: SubParserAction) -> argparse.ArgumentParser: | ||||
|     parser = root.add_parser("add", help="add package", description="add package", | ||||
|                              formatter_class=argparse.ArgumentDefaultsHelpFormatter) | ||||
|     parser.add_argument("package", help="package base/name or archive path", nargs="+") | ||||
|     parser.add_argument("--now", help="run update function after", action="store_true") | ||||
|     parser.add_argument("--without-dependencies", help="do not add dependencies", action="store_true") | ||||
|     parser.set_defaults(handler=handlers.Add) | ||||
|     return parser | ||||
|  | ||||
| @ -39,4 +39,10 @@ class Add(Handler): | ||||
|         :param architecture: repository architecture | ||||
|         :param configuration: configuration instance | ||||
|         """ | ||||
|         Application(architecture, configuration).add(args.package, args.without_dependencies) | ||||
|         application = Application(architecture, configuration) | ||||
|         application.add(args.package, args.without_dependencies) | ||||
|         if not args.now: | ||||
|             return | ||||
|  | ||||
|         packages = application.get_updates(args.package, True, False, True, application.logger.info) | ||||
|         application.update(packages) | ||||
|  | ||||
| @ -8,6 +8,7 @@ from ahriman.core.configuration import Configuration | ||||
|  | ||||
| def _default_args(args: argparse.Namespace) -> argparse.Namespace: | ||||
|     args.package = [] | ||||
|     args.now = False | ||||
|     args.without_dependencies = False | ||||
|     return args | ||||
|  | ||||
| @ -22,3 +23,19 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc | ||||
|  | ||||
|     Add.run(args, "x86_64", configuration) | ||||
|     application_mock.assert_called_once() | ||||
|  | ||||
|  | ||||
| def test_run_with_updates(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None: | ||||
|     """ | ||||
|     must run command with updates after | ||||
|     """ | ||||
|     args = _default_args(args) | ||||
|     args.now = True | ||||
|     mocker.patch("pathlib.Path.mkdir") | ||||
|     mocker.patch("ahriman.application.application.Application.add") | ||||
|     application_mock = mocker.patch("ahriman.application.application.Application.update") | ||||
|     updates_mock = mocker.patch("ahriman.application.application.Application.get_updates") | ||||
|  | ||||
|     Add.run(args, "x86_64", configuration) | ||||
|     application_mock.assert_called_once() | ||||
|     updates_mock.assert_called_once() | ||||
|  | ||||
		Reference in New Issue
	
	Block a user