All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] recipetool.newappend: add -e/--edit argument
@ 2016-02-09 23:12 Christopher Larson
  0 siblings, 0 replies; only message in thread
From: Christopher Larson @ 2016-02-09 23:12 UTC (permalink / raw)
  To: openembedded-core; +Cc: Christopher Larson

From: Christopher Larson <chris_larson@mentor.com>

Signed-off-by: Christopher Larson <chris_larson@mentor.com>
---
 scripts/lib/recipetool/newappend.py | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/scripts/lib/recipetool/newappend.py b/scripts/lib/recipetool/newappend.py
index f9b8d85..5625a8e 100644
--- a/scripts/lib/recipetool/newappend.py
+++ b/scripts/lib/recipetool/newappend.py
@@ -25,6 +25,7 @@ import errno
 import logging
 import os
 import re
+import subprocess
 import sys
 
 
@@ -89,17 +90,26 @@ def newappend(args):
         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')
-- 
2.2.1



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-02-09 23:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-09 23:12 [PATCH] recipetool.newappend: add -e/--edit argument Christopher Larson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.