some code reformatting
[rsync/rsync.git] / options.c
index 434defd..02434d5 100644 (file)
--- a/options.c
+++ b/options.c
@@ -55,6 +55,9 @@ int am_sender=0;
 int recurse = 0;
 int am_daemon=0;
 int am_client=0;
+int do_stats=0;
+int do_progress=0;
+int keep_partial=0;
 
 int block_size=BLOCK_SIZE;
 
@@ -74,58 +77,71 @@ void usage(int F)
 {
   rprintf(F,"rsync version %s Copyright Andrew Tridgell and Paul Mackerras\n\n",
          VERSION);
-  rprintf(F,"Usage:\t%s [options] src user@host:dest\nOR",RSYNC_NAME);
-  rprintf(F,"\t%s [options] user@host:src dest\n\n",RSYNC_NAME);
-  rprintf(F,"Options:\n");
-  rprintf(F,"-v, --verbose            increase verbosity\n");
-  rprintf(F,"-c, --checksum           always checksum\n");
-  rprintf(F,"-a, --archive            archive mode\n");
-  rprintf(F,"-r, --recursive          recurse into directories\n");
-  rprintf(F,"-R, --relative           use relative path names\n");
-  rprintf(F,"-b, --backup             make backups (default ~ extension)\n");
-  rprintf(F,"-u, --update             update only (don't overwrite newer files)\n");
-  rprintf(F,"-l, --links              preserve soft links\n");
-  rprintf(F,"-L, --copy-links         treat soft links like regular files\n");
-  rprintf(F,"-H, --hard-links         preserve hard links\n");
-  rprintf(F,"-p, --perms              preserve permissions\n");
-  rprintf(F,"-o, --owner              preserve owner (root only)\n");
-  rprintf(F,"-g, --group              preserve group\n");
-  rprintf(F,"-D, --devices            preserve devices (root only)\n");
-  rprintf(F,"-t, --times              preserve times\n");  
-  rprintf(F,"-S, --sparse             handle sparse files efficiently\n");
-  rprintf(F,"-n, --dry-run            show what would have been transferred\n");
-  rprintf(F,"-W, --whole-file         copy whole files, no incremental checks\n");
-  rprintf(F,"-x, --one-file-system    don't cross filesystem boundaries\n");
-  rprintf(F,"-B, --block-size SIZE    checksum blocking size\n");  
-  rprintf(F,"-e, --rsh COMMAND        specify rsh replacement\n");
-  rprintf(F,"    --rsync-path PATH    specify path to rsync on the remote machine\n");
-  rprintf(F,"-C, --cvs-exclude        auto ignore files in the same way CVS does\n");
-  rprintf(F,"    --delete             delete files that don't exist on the sending side\n");
-  rprintf(F,"    --force              force deletion of directories even if not empty\n");
-  rprintf(F,"    --numeric-ids        don't map uid/gid values by user/group name\n");
-  rprintf(F,"    --timeout TIME       set IO timeout in seconds\n");
-  rprintf(F,"-I, --ignore-times       don't exclude files that match length and time\n");
-  rprintf(F,"-T  --temp-dir DIR       create temporary files in directory DIR\n");
-  rprintf(F,"-z, --compress           compress file data\n");
-  rprintf(F,"    --exclude FILE       exclude file FILE\n");
-  rprintf(F,"    --exclude-from FILE  exclude files listed in FILE\n");
-  rprintf(F,"    --include FILE       don't exclude file FILE\n");
-  rprintf(F,"    --include-from FILE  don't exclude files listed in FILE\n");
-  rprintf(F,"    --suffix SUFFIX      override backup suffix\n");  
-  rprintf(F,"    --version            print version number\n");  
-  rprintf(F,"    --daemon             run as a rsync daemon\n");  
-  rprintf(F,"    --config FILE        specify alternate rsyncd.conf file\n");  
-  rprintf(F,"    --port PORT          specify alternate rsyncd port number\n");  
+
+  rprintf(F,"rsync is a file transfer program capable of efficient remote update\nvia a fast differencing algorithm.\n\n");
+
+  rprintf(F,"Usage: rsync [OPTION]... SRC [USER@]HOST:DEST\n");
+  rprintf(F,"  or   rsync [OPTION]... [USER@]HOST:SRC DEST\n");
+  rprintf(F,"  or   rsync [OPTION]... SRC DEST\n");
+  rprintf(F,"  or   rsync [OPTION]... [USER@]HOST::SRC DEST\n");
+  rprintf(F,"  or   rsync [OPTION]... SRC [USER@]HOST::DEST\n");
+  rprintf(F,"\nOptions\n");
+  rprintf(F," -v, --verbose               increase verbosity\n");
+  rprintf(F," -c, --checksum              always checksum\n");
+  rprintf(F," -a, --archive               archive mode\n");
+  rprintf(F," -r, --recursive             recurse into directories\n");
+  rprintf(F," -R, --relative              use relative path names\n");
+  rprintf(F," -b, --backup                make backups (default ~ extension)\n");
+  rprintf(F," -u, --update                update only (don't overwrite newer files)\n");
+  rprintf(F," -l, --links                 preserve soft links\n");
+  rprintf(F," -L, --copy-links            treat soft links like regular files\n");
+  rprintf(F," -H, --hard-links            preserve hard links\n");
+  rprintf(F," -p, --perms                 preserve permissions\n");
+  rprintf(F," -o, --owner                 preserve owner (root only)\n");
+  rprintf(F," -g, --group                 preserve group\n");
+  rprintf(F," -D, --devices               preserve devices (root only)\n");
+  rprintf(F," -t, --times                 preserve times\n");  
+  rprintf(F," -S, --sparse                handle sparse files efficiently\n");
+  rprintf(F," -n, --dry-run               show what would have been transferred\n");
+  rprintf(F," -W, --whole-file            copy whole files, no incremental checks\n");
+  rprintf(F," -x, --one-file-system       don't cross filesystem boundaries\n");
+  rprintf(F," -B, --block-size=SIZE       checksum blocking size\n");  
+  rprintf(F," -e, --rsh=COMMAND           specify rsh replacement\n");
+  rprintf(F,"     --rsync-path=PATH       specify path to rsync on the remote machine\n");
+  rprintf(F," -C, --cvs-exclude           auto ignore files in the same way CVS does\n");
+  rprintf(F,"     --delete                delete files that don't exist on the sending side\n");
+  rprintf(F,"     --partial               keep partially transferred files\n");
+  rprintf(F,"     --force                 force deletion of directories even if not empty\n");
+  rprintf(F,"     --numeric-ids           don't map uid/gid values by user/group name\n");
+  rprintf(F,"     --timeout=TIME          set IO timeout in seconds\n");
+  rprintf(F," -I, --ignore-times          don't exclude files that match length and time\n");
+  rprintf(F," -T  --temp-dir=DIR          create temporary files in directory DIR\n");
+  rprintf(F," -z, --compress              compress file data\n");
+  rprintf(F,"     --exclude=PATTERN       exclude file FILE\n");
+  rprintf(F,"     --exclude-from=PATTERN  exclude files listed in FILE\n");
+  rprintf(F,"     --include=PATTERN       don't exclude file FILE\n");
+  rprintf(F,"     --include-from=PATTERN  don't exclude files listed in FILE\n");
+  rprintf(F,"     --suffix=SUFFIX         override backup suffix\n");  
+  rprintf(F,"     --version               print version number\n");  
+  rprintf(F,"     --daemon                run as a rsync daemon\n");  
+  rprintf(F,"     --config=FILE           specify alternate rsyncd.conf file\n");  
+  rprintf(F,"     --port=PORT             specify alternate rsyncd port number\n");
+  rprintf(F,"     --stats                 give some file transfer stats\n");  
+  rprintf(F,"     --progress              show progress during transfer\n");  
+  rprintf(F," -h, --help                  show this help screen\n");
 
   rprintf(F,"\n");
   rprintf(F,"the backup suffix defaults to %s\n",BACKUP_SUFFIX);
   rprintf(F,"the block size defaults to %d\n",BLOCK_SIZE);  
+
+  rprintf(F,"\nPlease see the rsync(1) and rsyncd.conf(5) man pages for full documentation\n");
+  rprintf(F,"See http://samba.anu.edu.au/rsync/ for updates and bug reports\n");
 }
 
 enum {OPT_VERSION,OPT_SUFFIX,OPT_SENDER,OPT_SERVER,OPT_EXCLUDE,
       OPT_EXCLUDE_FROM,OPT_DELETE,OPT_NUMERIC_IDS,OPT_RSYNC_PATH,
       OPT_FORCE,OPT_TIMEOUT,OPT_DAEMON,OPT_CONFIG,OPT_PORT,
-      OPT_INCLUDE, OPT_INCLUDE_FROM};
+      OPT_INCLUDE, OPT_INCLUDE_FROM, OPT_STATS, OPT_PARTIAL, OPT_PROGRESS};
 
 static char *short_options = "oblLWHpguDCtcahvrRIxnSe:B:T:z";
 
@@ -170,6 +186,9 @@ static struct option long_options[] = {
   {"temp-dir",    1,     0,    'T'},
   {"compress",   0,     0,    'z'},
   {"daemon",      0,     0,    OPT_DAEMON},
+  {"stats",       0,     0,    OPT_STATS},
+  {"progress",    0,     0,    OPT_PROGRESS},
+  {"partial",     0,     0,    OPT_PARTIAL},
   {"config",      1,     0,    OPT_CONFIG},
   {"port",        1,     0,    OPT_PORT},
   {0,0,0,0}};
@@ -185,8 +204,9 @@ void parse_arguments(int argc, char *argv[])
       switch (opt) 
        {
        case OPT_VERSION:
-         printf("rsync version %s  protocol version %d\n",
+         rprintf(FINFO,"rsync version %s  protocol version %d\n\n",
                 VERSION,PROTOCOL_VERSION);
+         rprintf(FINFO,"Written by Andrew Tridgell and Paul Mackerras\n");
          exit_cleanup(0);
 
        case OPT_SUFFIX:
@@ -364,6 +384,18 @@ void parse_arguments(int argc, char *argv[])
                am_daemon = 1;
                break;
 
+       case OPT_STATS:
+               do_stats = 1;
+               break;
+
+       case OPT_PROGRESS:
+               do_progress = 1;
+               break;
+
+       case OPT_PARTIAL:
+               keep_partial = 1;
+               break;
+
        case OPT_CONFIG:
                config_file = optarg;
                break;
@@ -459,6 +491,9 @@ void server_options(char **args,int *argc)
   if (delete_mode)
     args[ac++] = "--delete";
 
+  if (keep_partial)
+    args[ac++] = "--partial";
+
   if (force_delete)
     args[ac++] = "--force";