import logging
import os
import re
+import subprocess
import sys
bb.utils.mkdirhier(os.path.dirname(append_path))
try:
- open(append_path, 'a')
+ open(append_path, 'a').close()
except (OSError, IOError) as exc:
logger.critical(str(exc))
return 1
- print(append_path)
+ if args.edit:
+ editor = os.getenv('VISUAL', os.getenv('EDITOR', 'vi'))
+ try:
+ return subprocess.check_call([editor, append_path, recipe_path])
+ except OSError as exc:
+ logger.error("Execution of editor '%s' failed: %s", editor, exc)
+ return 1
+ else:
+ print(append_path)
def register_commands(subparsers):
parser = subparsers.add_parser('newappend',
help='Create a bbappend for the specified target in the specified layer')
+ parser.add_argument('-e', '--edit', help='Edit the new append. This obeys $VISUAL if set, otherwise $EDITOR, otherwise vi.', action='store_true')
parser.add_argument('-w', '--wildcard-version', help='Use wildcard to make the bbappend apply to any recipe version', action='store_true')
parser.add_argument('destlayer', help='Base directory of the destination layer to write the bbappend to', type=layer)
parser.add_argument('target', help='Target recipe/provide to append')