[parted-devel] Re: Parted 2.0 plans

Debarshi 'Rishi' Ray debarshi.ray at gmail.com
Wed Nov 22 22:54:02 CET 2006


> I think -l is more clear. It'll basically "list" the devices. But
> another options would be put one as an alias to the other. Would work
> fine.
>
> Basically, I still think -l is clear.

> Why you didn't use _print_all ();?

a. --all is now --list
b. print_all is no more

Please find patch attached.

Happy hacking,
Debarshi
-- 
I only work when I am not doing any assignments.
-------------- next part --------------
From 751a0fa942c448e7d001ae8874162f7de294ae27 Mon Sep 17 00:00:00 2001
From: Debarshi Ray <rishi at gnu.org>
Date: Thu, 23 Nov 2006 03:22:55 +0000
Subject: Change --all to --list

---
 parted/parted.c |   26 +++++++++++---------------
 1 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/parted/parted.c b/parted/parted.c
index e948808..ddc1962 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -64,9 +64,9 @@ typedef struct {
 
 static struct option    options[] = {
         /* name, has-arg, string-return-val, char-return-val */
-        {"all",         0, NULL, 'a'},
         {"help",        0, NULL, 'h'},
         {"interactive", 0, NULL, 'i'},
+        {"list",        0, NULL, 'l'},
         {"script",      0, NULL, 's'},
         {"version",     0, NULL, 'v'},
         {NULL,          0, NULL, 0}
@@ -74,9 +74,9 @@ static struct option    options[] = {
 #endif
 
 static char*    options_help [][2] = {
-        {"all",         N_("displays partition tables of all available devices")},
         {"help",        N_("displays this help message")},
         {"interactive", N_("where necessary, prompts for user intervention")},
+        {"list",        N_("lists the partition tables of all available devices")},
         {"script",      N_("never prompts for user intervention")},
         {"version",     N_("displays the version")},
         {NULL,          NULL}
@@ -126,7 +126,7 @@ static Command* commands [256] = {NULL};
 static PedTimer* timer;
 static TimerContext timer_context;
 
-static int print_all ();
+static int _print_all (int cli);
 static void _done (PedDevice* dev);
 
 static void
@@ -1238,7 +1238,7 @@ do_print (PedDevice** dev)
         }
 
         if (has_all_arg)
-                return print_all();
+                return _print_all (0);
 
         start = ped_unit_format (*dev, 0);
         end = ped_unit_format_byte (*dev, (*dev)->length * (*dev)->sector_size
@@ -1372,7 +1372,7 @@ error:
 }
 
 static int
-print_all (void)
+_print_all (int cli)
 {
         PedDevice *current_dev = NULL;
 
@@ -1383,6 +1383,9 @@ print_all (void)
                 printf ("\n");
         }    
 
+        if(cli)
+                exit(0);
+
         return 1;
 }
 
@@ -2106,13 +2109,6 @@ #endif /* ENABLE_NLS */
 }
 
 void
-_print_all ()
-{
-        print_all();
-        exit(0);
-}
-
-void
 _version ()
 {
 printf (prog_name);
@@ -2127,18 +2123,18 @@ int     opt;
 while (1)
 {
 #ifdef HAVE_GETOPT_H
-        opt = getopt_long (*argc_ptr, *argv_ptr, "ahisv",
+        opt = getopt_long (*argc_ptr, *argv_ptr, "hilsv",
                            options, NULL);
 #else
-        opt = getopt (*argc_ptr, *argv_ptr, "ahisv");
+        opt = getopt (*argc_ptr, *argv_ptr, "hilsv");
 #endif
         if (opt == -1)
                 break;
 
         switch (opt) {
-                case 'a': _print_all(); break;
                 case 'h': help_msg (); break;
                 case 'i': opt_script_mode = 0; break;
+                case 'l': _print_all(1); break;
                 case 's': opt_script_mode = 1; break;
                 case 'v': _version (); break;
         }
-- 
1.4.2.4


More information about the parted-devel mailing list