#!/usr/bin/perl

=head1 NAME

ddtc - ddts client tool to help translators and reviewers.

=head1 SYNOPSIS

ddtc [OPTIONS] COMMAND [ARGUMENTS]

=head1 DESCRIPTION

This script helps both translators and reviewers with parsing mails from the
ddts, splitting them into individual package files, sending reviews and
patching buggy translations.

Before sending back the translation or the review to the server, the script
performs a few tests on it and does not sent it if one of the following
succeeds:

=over 4

=item - number of paragraphs is different in the description and its translation,

=item - line length is more than 80 characters,

=item - I<E<lt>tabE<gt>> character is found,

=item - line starts with a dot (I<.>) followed by other characters.

=back

It can also be run in interactive mode if no command is provided. In this case,
menus are displayed to prompt the user for commands.

=head1 COMMANDS

Here is the basic process:

=over 4

=item - Receiving mail from the ddts

Pass the whole mail (i.e. with header and Mime parts) you received from the
ddts to the standard input of this script, providing the I<parse> command.

If it finds descriptions to translate, it creates a F<package.todo> file for
each of them in your F<Base_dir/tr> directory, diffing it with the preceding
you have already translated if it exists.

If it finds descriptions to review, it creates a F<package.todo> file for each
of them in your F<Base_dir/rev> directory. If a preceding review exists, it
diffs both and write the diff or set the description as reviewed if there is no
difference.

If it finds a bug report, it creates a F<package.bug> file in your
F<Base_dir/bug> directory, it merges all bug reports to ease corrections. It
also tries to detect collisions (see below).

=item - Working with the files

=over 4

=item - Translating

Rename the F<package.todo> file in your F<Base/tr> directory into
F<package.tr>.

Edit it with your favorite text editor.

=item - Reviewing

Rename the F<package.todo> file in your F<Base_dir/rev> directory into
F<package.rev>. Do not edit the F<package> file (with no extension), it is used
internally by ddtc.

Edit it with your favorite text editor. You can add comments that will be sent
to the translator by adding lines beginning with `B<E<gt>E<gt> >' (your
I<$Comment> variable contents followed by a mandatory space character).

If a translation has already been reviewed and has been modified the script
show you the differences between both versions.  Lines beginning with
`B<E<gt>E<gt>-->' correspond to your last version you reviewed, replace this by
`B<+E<gt>-->' if you think the translator is still wrong.  Lines beginning with
`B<E<gt>E<gt>++>' are the new translator's version, replace this by
`B<+E<gt>++>' if you agree with the translator.  Of course, if you still
disagree with the translator, you can add comments as indicated above.

=item - Fixing bugs

Rename the F<package.bug> file in your F<Base_dir/bug> directory into
F<package.fix>.

Edit it with your favorite text editor. It contains all changes and comments of
the reviewers.

Lines beginning with `B<E<gt>E<gt>>' are comments and doesn't have to be
removed. Lines beginning with `B<E<gt>E<gt>X+>' are suggested corrections,
replace this by `B<+E<gt>X+>' if you want to validate it. Lines beginning with
`B<E<gt>E<gt>-->' are your last translation, replace this by `B<+E<gt>-->' if
you don't want to accept suggested corrections.

Run the script providing the I<fix> command. It creates a new F<package.tr>
file in your F<Base_dir/tr> directory containing the unchanged lines and the
lines you have selected.

To prevent collisions (reviewers sending review based on a different version
than yours), don't send fixed descriptions too often (once a day should be
fine), retrieve your mails and parse them just before fixing, send the fixed
description as soon as possible afterward.

=back

=item - Sending files back to the ddts

Run the script providing the I<mail> command.

It sends descriptions from F<package.tr> and F<package.rev> files back to the
ddts renaming them into F<package.sent> and closing bugs if necessary.

=item - Sending commands to the server

Run the script providing the commands you want to be sent to the server. It
checks the commands and send them to the server.

Available commands:

=over 4

=item section I<section name>

=item sget I<package name>

=item get I<package name>

=item get I<number of packages>

=item review I<package name>

=item review I<number of packages>

=item getbug I<list of bug numbers>

=item btsclose I<list of bug numbers>

=item notification I<list of languages>

=item listtranslatedpackages

=item status

=item noneveraguide

=item neveraguide

=item noguide

=item guide

=back

In each set: I<sget>/I<get>/I<review>/I<getbug>/I<btsclose>/I<notification>,
I<noneveraguide>/I<neveraguide> and I<noguide>/I<guide>, only the first found
command is used. The script automatically adds language, encoding and mail
address (I<Mail_in>) if requested, I<noguide> is default.

Due to server limitation, to avoid risk of deny of service attack, you cannot
receive for more than 9 new documents at the same time. The script does not
check for this, but the server will.

For I<sget>, I<get>, I<review>, I<status> and I<listtranslatedpackages> you
have either to define the I<$Language> variable in you F<.ddtcrc> configuration
file, or to provide a language extension via the I<--lang> or I<-l> option.

=item - Cleaning directories

Run the script providing the I<clean> command.

It removes unnecessary files in ddtc directories but temporary one as this
directory should be a system wide temporary directory cleaned via system
scheduled threads, but for debugging reason.

=item - Getting statistics about my work

Run the script providing the I<stats> command.

It prints figures based on file counts, it may not be accurate if directory
cleaning has not been made before.

=back

=head1 OPTIONS

Verbosity level:

=over 4

=item I<-q, --quiet>

quiet mode

=item I<-v>

verbose, start at level I<$Debug + 1>, add more for more verbosity (see below)

=item I<--verbose n>

set verbosity level to I<n> (see below)

=back

cc mails to one-self:

=over 4

=item I<-s, --mail-self>

send mails also to oneself

=item I<-n, --nomail-self>

don't send mails to oneself

=back

other:

=over 4

=item I<-l, --lang>

language extension to use when asking for new documents to translate or to
review

=item I<--ddtc-bug>

send review in special format. Ask your language coordinator before using
this option.

=item I<--noddtc-bug>

send review in standard format.

=item I<-V, --version>

print version and exit

=item I<-h, --help>

print usage and exit

=back

=head2 Verbosity Level

=over 4

=item I<0> quiet

only warnings and errors

=item I<1> normal

package names, reviewer/translator names and bugs numbers

=item I<2> reserved

for internal use

=item I<3> debug normal

names of subroutines

=item I<4> debug verbose

names and short arguments of subroutines

=item I<5> debug very verbose

names, arguments and return values of subroutines

=item I<9> debug don't send mails

same as 5 but send mails to oneself instead of ddts

=back

level 5 and 9 are really verbose, so you should direct the output to a file.

=head1 SEE ALSO

ddtcrc(5).

http://ddtp.debian.org/ddtp-text/misc/ddts-faq.txt.

http://ddtp.debian.org/ddtp-text/guides/guide.txt.

http://ddtp.debian.org/ddtp-text/guides/review.txt.

=head1 AUTHOR

Nicolas Bertolissio <bertol@debian.org>
  
=cut
