Add format string doku, simplify format string handling.
[adu.git] / select.ggo
index 660839b28c5fdc6236a3e1958e530dc67bbd0885..e8a5f95dffa2f0fe8d0fea2223d9599a296c38b6 100644 (file)
@@ -91,57 +91,94 @@ details="
        to the base dir.
 "
 
-########################
-section "Format strings"
-########################
-
-option "global-list-format" -
-#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-"How to format the global list"
-string typestr="<format>"
-default="%(size:r:8) %(files:r:8) %(dirname)\n"
-details="
-       size: Total size of all files
-       files: The number of files
-       dirname: The name of the directory
-"
-
+option "format" f
+#~~~~~~~~~~~~~~~~
+"How to format the output"
+string typestr="<format_string>"
 optional
-option "global-summary-format" -
-#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-"How to format the global summary"
-string typestr="<format>"
-default="#directories: %(dirs), #files: %(files), size: %(size)\n\n"
 details="
-       dirs: The number of directories
-       files: The number of files
-       size: Total size of all files
-"
-optional
+       A string that specifies how the output of the select query is
+       goint to be formated.  Depending on the chosen select-mode,
+       several conversion specifiers are available and a different
+       default value for this option applies.
 
-option "user-list-format" -
-#~~~~~~~~~~~~~~~~~~~~~~~~~~
-"How to format the user list"
-string typestr="<format>"
-default="%(size:r:5) %(files:r:5) %(dirname)\n"
-details="
-       pw_name: The user name
-       uid: The user id
-       files: The number of files
-       size: size of all files in that directory
-       dirname: The name of the directory
-"
-optional
-option "user-summary-format" -
-#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-"How to format the user summary"
-string typestr="<format>"
-default="%(pw_name:l:16) %(uid:r:5) %(dirs:r:5) %(files:r:5) %(size:r:5)\n"
-details="
-       pw_name: The user name
-       uid: The user id
-       dirs: The number of directories
-       files: The number of files
-       size: Total size of all files
+       adu knows four different types of directives: string, id,
+       count and size.  These are explained in more detail below.
+
+       The general syntax for string and id directives is %(name:a:w)
+       where \"name\" is the name of the directive, \"a\" specifies
+       the alignment and \"w\" is the width specifier which allows
+       to give a field width.
+
+       The alignment specifier is a single character: Either \"l\",
+       \"r\", or \"c\" may be given to specify left, right and
+       centered alignment respectively. The with specifier is a
+       positive integer.  Both \"a\" and \"w\" are optional.
+
+       A string directive supported by adu is \"dirname\" which is
+       subsitituted by the name of the directory. It is available
+       if either user_list or global_list mode was selected via
+       --select-mode.
+
+       Examples:
+
+               \"%(diname)\" # print dirname without any padding
+               \"%(dirname:c:20)\" # center dirname in a 20 chars wide field
+
+       The other two types of directives, count and size, are used
+       for numbers. The syntax for these is %(name:a:w:u). The \"a\"
+       and the \"w\" specifier have the same meaning as for the string
+       and id directives. The additional \"u\" specifier selects a unit
+       in which the number that corresponds to the directive should
+       be formated. All three specifiers are optional.
+
+       Possible units are the characters of the set \" bkmgtBKMGT\"
+       specifying bytes, kilobytes, megabytes, gigabytes and
+       terabytes respectively. The difference between the lower and
+       the upper case variants is that the lower case specifiers
+       select 1024-based units while the upper case specifiers use
+       1000 as the basis.
+
+       The whitespace character is like \"b\", but a space character
+       is printed instead of a unit.
+
+       Two more characters \"h\" and \"H\" (human-readable) are also
+       available that choose an appropriate unit depending on the
+       size of the number being printed.
+
+       An asterisk prepended to the unit specifier prevents the
+       unit from being printed. This is useful mainly for feeding
+       the output of adu to scripts that do not expect units.
+
+       In order to print a percent sign, use \"%%\". Moreover, adu
+       understands \"\n\" and \"\t\" and outputs a newline and a
+       tab character for these combinations respectively.
+
+       Examples:
+
+               \"%(size:r::G)\" # print size in gigabytes right-aligned
+               \"%(size:r5::G)\" # as before, but use 5 char wide field
+               \"%(size:r5::*G)\" # as before, but supress trailing \"G\"
+
+       List of directives and types known to adu, together with their types:
+
+               name            type            meaning
+               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+               pw_name         string          user name
+               uid             id              user id
+               files           count           number of files
+               dirname         string          name of the directory
+               size            size            total size/ directory size
+               dirs            count           number of directories
+
+       Not all directives are available for each mode:
+
+               name            available in directives
+               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+               pw_name         user_list, user_summary
+               uid             user_list, user_summary
+               files           everywhere
+               dirname         user_list, global_list
+               size            everywhere
+               dirs            suer_summary, global_summary
 "
-optional