blob: d5b980a1c03ed3f49dec3ac504d45cae2b2c3d69 [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001# Recipe creation tool - edit plugin
2#
3# This sub-command edits the recipe and appends for the specified target
4#
5# Example: recipetool edit busybox
6#
7# Copyright (C) 2018 Mentor Graphics Corporation
8#
Brad Bishopc342db32019-05-15 21:57:59 -04009# SPDX-License-Identifier: GPL-2.0-only
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080010#
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080011
12import argparse
13import errno
14import logging
15import os
16import re
17import subprocess
18import sys
19import scriptutils
20
21
22logger = logging.getLogger('recipetool')
23tinfoil = None
24
25
26def tinfoil_init(instance):
27 global tinfoil
28 tinfoil = instance
29
30
31def edit(args):
32 import oe.recipeutils
33
34 recipe_path = tinfoil.get_recipe_file(args.target)
35 appends = tinfoil.get_file_appends(recipe_path)
36
Andrew Geisslerd25ed322020-06-27 00:28:28 -050037 return scriptutils.run_editor([recipe_path] + list(appends), logger)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080038
39
40def register_commands(subparsers):
41 parser = subparsers.add_parser('edit',
42 help='Edit the recipe and appends for the specified target. This obeys $VISUAL if set, otherwise $EDITOR, otherwise vi.')
43 parser.add_argument('target', help='Target recipe/provide to edit')
44 parser.set_defaults(func=edit, parserecipes=True)