Re: [pacman-dev] [RFC v3 06/13] paccache: streamline usage function

2016-09-30 Thread Gordian Edenhofer
On Fri, 2016-09-30 at 08:14 -0400, Dave Reisner wrote:
> On Fri, Sep 30, 2016 at 01:47:54PM +0200, Gordian Edenhofer wrote:
> > 
> > Signed-off-by: Gordian Edenhofer 
> > ---
> >  contrib/paccache.sh.in | 83 
> > --
> >  1 file changed, 53 insertions(+), 30 deletions(-)
> > 
> > diff --git a/contrib/paccache.sh.in b/contrib/paccache.sh.in
> > index 02fae52..78f566f 100644
> > --- a/contrib/paccache.sh.in
> > +++ b/contrib/paccache.sh.in
> > @@ -30,6 +30,17 @@ declaredelim=$'\n' keep=3 movedir= scanarch=
> >  QUIET=0
> >  USE_COLOR='y'
> >  
> > +# gettext initialization
> > +export TEXTDOMAIN='pacman'
> > +export TEXTDOMAINDIR='@localedir@'
> > +
> > +# Determine whether we have gettext; make it a no-op if we do not
> > +if ! type -p gettext >/dev/null; then
> > +   gettext() {
> > +   printf "%s\n" "$@"
> > +   }
> > +fi
> > +
> >  m4_include(../scripts/library/output_format.sh)
> >  m4_include(../scripts/library/parseopts.sh)
> >  
> > @@ -172,36 +183,48 @@ summarize() {
> >  }
> >  
> >  usage() {
> > -   cat < > -${myname} (pacman) v${myver}
> > -
> > -A flexible pacman cache cleaning utility.
> > -
> > -Usage: ${myname}  [options] [targets...]
> > -
> > -  Operations:
> > --d, --dryrun  perform a dry run, only finding
> > candidate packages.
> > --m, --move   move candidate packages to "dir".
> > --r, --remove  remove candidate packages.
> > -
> > -  Options:
> > --a, --arch  scan for "arch" (default: all
> > architectures).
> > --c, --cachedir   scan "dir" for packages. can be used
> > more than once.
> > -  (default: read from
> > @sysconfdir@/pacman.conf).
> > --f, --force   apply force to mv(1) and rm(1)
> > operations.
> > --h, --helpdisplay this help message and exit.
> > --i, --ignore    ignore "pkgs", comma-separated.
> > Alternatively, specify
> > -  "-" to read package names from stdin,
> > newline-
> > -  delimited.
> > --k, --keep   keep "num" of each package in the cache
> > (default: 3).
> > ---nocolor remove color from output.
> > --q, --quiet   minimize output
> > --u, --uninstalled target uninstalled packages.
> > --v, --verbose increase verbosity. specify up to 3
> > times.
> > --z, --nulluse null delimiters for candidate names
> > (only with -v
> > -  and -vv).
> > -
> > -EOF
> > +   printf "%s (pacman) %s\n" "$myname" "$myver"
> > +   echo
> > +   printf -- "$(gettext "A flexible pacman cache cleaning
> > utility")\n"
> > +   echo
> > +   printf -- "$(gettext "Usage: %s  [options]
> > [targets...]")\n" "$0"
> > +   echo
> > +   printf -- "$(gettext "Operations:")\n"
> > +   printf -- "  -d, --dryrun  "
> > +   printf -- "$(gettext "Perform a dry run, only finding
> > candidate packages")\n"
> > +   printf -- "  -m, --move   "
> > +   printf -- "$(gettext "Move candidate packages to
> > \"dir\"")\n"
> > +   printf -- "  -r, --remove  "
> > +   printf -- "$(gettext "Remove candidate packages")\n"
> > +   echo
> > +   printf -- "$(gettext "Options:")\n"
> > +   printf -- "  -a, --arch  "
> > +   printf -- "$(gettext "Scan for \"arch\" (default: all
> > architectures)")\n"
> > +   printf -- "  -c, --cachedir   "
> > +   printf -- "$(gettext "Scan \"dir\" for packages. Can be
> > used more than once.\n\
> > +   (default: read from %s).")\n"
> > "@sysconfdir@/pacman.conf"
> > +   printf -- "  -f, --force   "
> > +   printf -- "$(gettext "Apply force to mv(1) and rm(1)
> > operations")\n" "\$srcdir/"
> > +   printf -- "  -h, --help"
> > +   printf -- "$(gettext "Display this help message and
> > exit")\n"
> > +   printf -- "  -i, --ignore    "
> > +   printf -- "$(gettext "Ignore \"pkgs\", comma-separated.
> > Alternatively, specify\n\
> > +   \"-\" to read package names from
> > stdin, newline-\n\
> > +   delimited.")\n" "\$srcdir/"
> > +   printf -- "  -k, --keep   "
> > +   printf -- "$(gettext "Keep \"num\" of each package in the
> > cache (default: 3)")\n"
> > +   printf -- "  -q, --quiet   "
> > +   printf -- "$(gettext "Minimize output")\n"
> > +   printf -- "  -u, --uninstalled "
> > +   printf -- "$(gettext "Target uninstalled packages")\n"
> > +   printf -- "  -v, --verbose "
> > +   printf -- "$(gettext "Increase verbosity. specify up to 3
> > times.")\n"
> > +   printf -- "  -z, --null"
> > +   printf -- "$(gettext "Use null delimiters for candidate
> > names (only with -v\n\
> > +   and -vv)")\n"
> > +   printf -- "  --nocolor "
> > +   printf -- "$(gettext "Remove color from output")\n"
> > +   echo
> 
> I'm going to need convincing that this fits the definition of
> "streamlined" compared to the

Re: [pacman-dev] [RFC v3 06/13] paccache: streamline usage function

2016-09-30 Thread Dave Reisner
On Fri, Sep 30, 2016 at 01:47:54PM +0200, Gordian Edenhofer wrote:
> Signed-off-by: Gordian Edenhofer 
> ---
>  contrib/paccache.sh.in | 83 
> --
>  1 file changed, 53 insertions(+), 30 deletions(-)
> 
> diff --git a/contrib/paccache.sh.in b/contrib/paccache.sh.in
> index 02fae52..78f566f 100644
> --- a/contrib/paccache.sh.in
> +++ b/contrib/paccache.sh.in
> @@ -30,6 +30,17 @@ declaredelim=$'\n' keep=3 movedir= scanarch=
>  QUIET=0
>  USE_COLOR='y'
>  
> +# gettext initialization
> +export TEXTDOMAIN='pacman'
> +export TEXTDOMAINDIR='@localedir@'
> +
> +# Determine whether we have gettext; make it a no-op if we do not
> +if ! type -p gettext >/dev/null; then
> + gettext() {
> + printf "%s\n" "$@"
> + }
> +fi
> +
>  m4_include(../scripts/library/output_format.sh)
>  m4_include(../scripts/library/parseopts.sh)
>  
> @@ -172,36 +183,48 @@ summarize() {
>  }
>  
>  usage() {
> - cat < -${myname} (pacman) v${myver}
> -
> -A flexible pacman cache cleaning utility.
> -
> -Usage: ${myname}  [options] [targets...]
> -
> -  Operations:
> --d, --dryrun  perform a dry run, only finding candidate packages.
> --m, --move   move candidate packages to "dir".
> --r, --remove  remove candidate packages.
> -
> -  Options:
> --a, --arch  scan for "arch" (default: all architectures).
> --c, --cachedir   scan "dir" for packages. can be used more than 
> once.
> -  (default: read from @sysconfdir@/pacman.conf).
> --f, --force   apply force to mv(1) and rm(1) operations.
> --h, --helpdisplay this help message and exit.
> --i, --ignoreignore "pkgs", comma-separated. Alternatively, 
> specify
> -  "-" to read package names from stdin, newline-
> -  delimited.
> --k, --keep   keep "num" of each package in the cache (default: 
> 3).
> ---nocolor remove color from output.
> --q, --quiet   minimize output
> --u, --uninstalled target uninstalled packages.
> --v, --verbose increase verbosity. specify up to 3 times.
> --z, --nulluse null delimiters for candidate names (only with 
> -v
> -  and -vv).
> -
> -EOF
> + printf "%s (pacman) %s\n" "$myname" "$myver"
> + echo
> + printf -- "$(gettext "A flexible pacman cache cleaning utility")\n"
> + echo
> + printf -- "$(gettext "Usage: %s  [options] [targets...]")\n" 
> "$0"
> + echo
> + printf -- "$(gettext "Operations:")\n"
> + printf -- "  -d, --dryrun  "
> + printf -- "$(gettext "Perform a dry run, only finding candidate 
> packages")\n"
> + printf -- "  -m, --move   "
> + printf -- "$(gettext "Move candidate packages to \"dir\"")\n"
> + printf -- "  -r, --remove  "
> + printf -- "$(gettext "Remove candidate packages")\n"
> + echo
> + printf -- "$(gettext "Options:")\n"
> + printf -- "  -a, --arch  "
> + printf -- "$(gettext "Scan for \"arch\" (default: all 
> architectures)")\n"
> + printf -- "  -c, --cachedir   "
> + printf -- "$(gettext "Scan \"dir\" for packages. Can be used more than 
> once.\n\
> + (default: read from %s).")\n" 
> "@sysconfdir@/pacman.conf"
> + printf -- "  -f, --force   "
> + printf -- "$(gettext "Apply force to mv(1) and rm(1) operations")\n" 
> "\$srcdir/"
> + printf -- "  -h, --help"
> + printf -- "$(gettext "Display this help message and exit")\n"
> + printf -- "  -i, --ignore"
> + printf -- "$(gettext "Ignore \"pkgs\", comma-separated. Alternatively, 
> specify\n\
> + \"-\" to read package names from stdin, 
> newline-\n\
> + delimited.")\n" "\$srcdir/"
> + printf -- "  -k, --keep   "
> + printf -- "$(gettext "Keep \"num\" of each package in the cache 
> (default: 3)")\n"
> + printf -- "  -q, --quiet   "
> + printf -- "$(gettext "Minimize output")\n"
> + printf -- "  -u, --uninstalled "
> + printf -- "$(gettext "Target uninstalled packages")\n"
> + printf -- "  -v, --verbose "
> + printf -- "$(gettext "Increase verbosity. specify up to 3 times.")\n"
> + printf -- "  -z, --null"
> + printf -- "$(gettext "Use null delimiters for candidate names (only 
> with -v\n\
> + and -vv)")\n"
> + printf -- "  --nocolor "
> + printf -- "$(gettext "Remove color from output")\n"
> + echo

I'm going to need convincing that this fits the definition of
"streamlined" compared to the current implementation.

  stream·line
  /ˈstrēmˌlīn/

  1.  design or provide with a form that presents very little resistance to a
  flow of air or water, increasing speed and ease of movement.
  2.  make (an organization or system

[pacman-dev] [RFC v3 06/13] paccache: streamline usage function

2016-09-30 Thread Gordian Edenhofer
Signed-off-by: Gordian Edenhofer 
---
 contrib/paccache.sh.in | 83 --
 1 file changed, 53 insertions(+), 30 deletions(-)

diff --git a/contrib/paccache.sh.in b/contrib/paccache.sh.in
index 02fae52..78f566f 100644
--- a/contrib/paccache.sh.in
+++ b/contrib/paccache.sh.in
@@ -30,6 +30,17 @@ declaredelim=$'\n' keep=3 movedir= scanarch=
 QUIET=0
 USE_COLOR='y'
 
+# gettext initialization
+export TEXTDOMAIN='pacman'
+export TEXTDOMAINDIR='@localedir@'
+
+# Determine whether we have gettext; make it a no-op if we do not
+if ! type -p gettext >/dev/null; then
+   gettext() {
+   printf "%s\n" "$@"
+   }
+fi
+
 m4_include(../scripts/library/output_format.sh)
 m4_include(../scripts/library/parseopts.sh)
 
@@ -172,36 +183,48 @@ summarize() {
 }
 
 usage() {
-   cat < [options] [targets...]
-
-  Operations:
--d, --dryrun  perform a dry run, only finding candidate packages.
--m, --move   move candidate packages to "dir".
--r, --remove  remove candidate packages.
-
-  Options:
--a, --arch  scan for "arch" (default: all architectures).
--c, --cachedir   scan "dir" for packages. can be used more than once.
-  (default: read from @sysconfdir@/pacman.conf).
--f, --force   apply force to mv(1) and rm(1) operations.
--h, --helpdisplay this help message and exit.
--i, --ignoreignore "pkgs", comma-separated. Alternatively, 
specify
-  "-" to read package names from stdin, newline-
-  delimited.
--k, --keep   keep "num" of each package in the cache (default: 3).
---nocolor remove color from output.
--q, --quiet   minimize output
--u, --uninstalled target uninstalled packages.
--v, --verbose increase verbosity. specify up to 3 times.
--z, --nulluse null delimiters for candidate names (only with -v
-  and -vv).
-
-EOF
+   printf "%s (pacman) %s\n" "$myname" "$myver"
+   echo
+   printf -- "$(gettext "A flexible pacman cache cleaning utility")\n"
+   echo
+   printf -- "$(gettext "Usage: %s  [options] [targets...]")\n" 
"$0"
+   echo
+   printf -- "$(gettext "Operations:")\n"
+   printf -- "  -d, --dryrun  "
+   printf -- "$(gettext "Perform a dry run, only finding candidate 
packages")\n"
+   printf -- "  -m, --move   "
+   printf -- "$(gettext "Move candidate packages to \"dir\"")\n"
+   printf -- "  -r, --remove  "
+   printf -- "$(gettext "Remove candidate packages")\n"
+   echo
+   printf -- "$(gettext "Options:")\n"
+   printf -- "  -a, --arch  "
+   printf -- "$(gettext "Scan for \"arch\" (default: all 
architectures)")\n"
+   printf -- "  -c, --cachedir   "
+   printf -- "$(gettext "Scan \"dir\" for packages. Can be used more than 
once.\n\
+   (default: read from %s).")\n" 
"@sysconfdir@/pacman.conf"
+   printf -- "  -f, --force   "
+   printf -- "$(gettext "Apply force to mv(1) and rm(1) operations")\n" 
"\$srcdir/"
+   printf -- "  -h, --help"
+   printf -- "$(gettext "Display this help message and exit")\n"
+   printf -- "  -i, --ignore"
+   printf -- "$(gettext "Ignore \"pkgs\", comma-separated. Alternatively, 
specify\n\
+   \"-\" to read package names from stdin, 
newline-\n\
+   delimited.")\n" "\$srcdir/"
+   printf -- "  -k, --keep   "
+   printf -- "$(gettext "Keep \"num\" of each package in the cache 
(default: 3)")\n"
+   printf -- "  -q, --quiet   "
+   printf -- "$(gettext "Minimize output")\n"
+   printf -- "  -u, --uninstalled "
+   printf -- "$(gettext "Target uninstalled packages")\n"
+   printf -- "  -v, --verbose "
+   printf -- "$(gettext "Increase verbosity. specify up to 3 times.")\n"
+   printf -- "  -z, --null"
+   printf -- "$(gettext "Use null delimiters for candidate names (only 
with -v\n\
+   and -vv)")\n"
+   printf -- "  --nocolor "
+   printf -- "$(gettext "Remove color from output")\n"
+   echo
 }
 
 version() {
-- 
2.10.0