diff mbox

[U-Boot,01/42] moveconfig: Add an option to skip prompts

Message ID 1472057546-10360-2-git-send-email-sjg@chromium.org
State Superseded
Delegated to: Tom Rini
Headers show

Commit Message

Simon Glass Aug. 24, 2016, 4:51 p.m. UTC
At present it is not easy to use moveconfig from a script since it asks
for user input a few times. Add a -y option to skip this and assume that
'y' was entered.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 tools/moveconfig.py | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

Comments

Masahiro Yamada Aug. 25, 2016, 1:45 a.m. UTC | #1
Hi Simon,


2016-08-25 1:51 GMT+09:00 Simon Glass <sjg@chromium.org>:
> At present it is not easy to use moveconfig from a script since it asks
> for user input a few times. Add a -y option to skip this and assume that
> 'y' was entered.


You can do as follows:

  yes | tools/moveconfig CONFIG_FOO CONFIG_BAR


If you want to respond 'no' to any prompts,

  yes n | tools/moveconfig CONFIG_FOO CONFIG_BAR




I do not mind it if people want to do it in a self-contained way, though.
Simon Glass Aug. 25, 2016, 12:04 p.m. UTC | #2
Hi Masahiro,

On 24 August 2016 at 19:45, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> Hi Simon,
>
>
> 2016-08-25 1:51 GMT+09:00 Simon Glass <sjg@chromium.org>:
>> At present it is not easy to use moveconfig from a script since it asks
>> for user input a few times. Add a -y option to skip this and assume that
>> 'y' was entered.
>
>
> You can do as follows:
>
>   yes | tools/moveconfig CONFIG_FOO CONFIG_BAR
>
>
> If you want to respond 'no' to any prompts,
>
>   yes n | tools/moveconfig CONFIG_FOO CONFIG_BAR
>
>
>
>
> I do not mind it if people want to do it in a self-contained way, though.

I much prefer tat the tool supports this directly, like fsck for
example. It could be changed to select what gets done, but from what I
can see at the moment, we normally want to remove old uses.

Regards,
Simon
diff mbox

Patch

diff --git a/tools/moveconfig.py b/tools/moveconfig.py
index 5eebab8..290270a 100755
--- a/tools/moveconfig.py
+++ b/tools/moveconfig.py
@@ -473,14 +473,15 @@  def cleanup_headers(configs, options):
       configs: A list of CONFIGs to remove.
       options: option flags.
     """
-    while True:
-        choice = raw_input('Clean up headers? [y/n]: ').lower()
-        print choice
-        if choice == 'y' or choice == 'n':
-            break
+    if not options.yes:
+        while True:
+            choice = raw_input('Clean up headers? [y/n]: ').lower()
+            print choice
+            if choice == 'y' or choice == 'n':
+                break
 
-    if choice == 'n':
-        return
+        if choice == 'n':
+            return
 
     patterns = []
     for config in configs:
@@ -552,14 +553,16 @@  def cleanup_extra_options(configs, options):
       configs: A list of CONFIGs to remove.
       options: option flags.
     """
-    while True:
-        choice = raw_input('Clean up CONFIG_SYS_EXTRA_OPTIONS? [y/n]: ').lower()
-        print choice
-        if choice == 'y' or choice == 'n':
-            break
+    if not options.yes:
+        while True:
+            choice = (raw_input('Clean up CONFIG_SYS_EXTRA_OPTIONS? [y/n]: ').
+                      lower())
+            print choice
+            if choice == 'y' or choice == 'n':
+                break
 
-    if choice == 'n':
-        return
+        if choice == 'n':
+            return
 
     configs = [ config[len('CONFIG_'):] for config in configs ]
 
@@ -1212,6 +1215,8 @@  def main():
                       help='the number of jobs to run simultaneously')
     parser.add_option('-r', '--git-ref', type='string',
                       help='the git ref to clone for building the autoconf.mk')
+    parser.add_option('-y', '--yes', action='store_true', default=False,
+                      help="respond 'yes' to any prompts")
     parser.add_option('-v', '--verbose', action='store_true', default=False,
                       help='show any build errors as boards are built')
     parser.usage += ' CONFIG ...'