format-manpage.pl 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. #!/usr/bin/perl
  2. # Format s3cmd.1 manpage
  3. # Usage:
  4. # s3cmd --help | format-manpage.pl > s3cmd.1
  5. use strict;
  6. my $commands = "";
  7. my $cfcommands = "";
  8. my $wscommands = "";
  9. my $options = "";
  10. while (<>) {
  11. if (/^Commands:/) {
  12. while (<>) {
  13. last if (/^\s*$/);
  14. my ($desc, $cmd, $cmdline);
  15. ($desc = $_) =~ s/^\s*(.*?)\s*$/$1/;
  16. ($cmdline = <>) =~ s/^\s*s3cmd (.*?) (.*?)\s*$/s3cmd \\fB$1\\fR \\fI$2\\fR/;
  17. $cmd = $1;
  18. $cmdline =~ s/-/\\-/g;
  19. if ($cmd =~ /^cf/) {
  20. $cfcommands .= ".TP\n$cmdline\n$desc\n";
  21. } elsif ($cmd =~ /^ws/) {
  22. $wscommands .= ".TP\n$cmdline\n$desc\n";
  23. } else {
  24. $commands .= ".TP\n$cmdline\n$desc\n";
  25. }
  26. }
  27. }
  28. if (/^Options:/) {
  29. my ($opt, $desc);
  30. while (<>) {
  31. last if (/^\s*$/);
  32. $_ =~ s/(.*?)\s*$/$1/;
  33. $desc = "";
  34. $opt = "";
  35. if (/^ (-.*)/) {
  36. $opt = $1;
  37. if ($opt =~ / /) {
  38. ($opt, $desc) = split(/\s\s+/, $opt, 2);
  39. }
  40. $opt =~ s/(-[^ ,=\.]+)/\\fB$1\\fR/g;
  41. # escape all single dashes
  42. $opt =~ s/-/\\-/g;
  43. $options .= ".TP\n$opt\n";
  44. } else {
  45. $_ =~ s/\s*(.*?)\s*$/$1/;
  46. $_ =~ s/(--[^ ,=\.]+)/\\fB$1\\fR/g;
  47. # escape word 'Cache-Control'
  48. $_ =~ s/'(\S+-\S+)'/\\&'$1'/g;
  49. # escape all single dashes
  50. $_ =~ s/-/\\-/g;
  51. $desc .= $_;
  52. }
  53. if ($desc) {
  54. $options .= "$desc\n";
  55. }
  56. }
  57. }
  58. }
  59. print "
  60. .\\\" !!! IMPORTANT: This file is generated from s3cmd \\-\\-help output using format-manpage.pl
  61. .\\\" !!! Do your changes either in s3cmd file or in 'format\\-manpage.pl' otherwise
  62. .\\\" !!! they will be overwritten!
  63. .TH s3cmd 1
  64. .SH NAME
  65. s3cmd \\- tool for managing Amazon S3 storage space and Amazon CloudFront content delivery network
  66. .SH SYNOPSIS
  67. .B s3cmd
  68. [\\fIOPTIONS\\fR] \\fICOMMAND\\fR [\\fIPARAMETERS\\fR]
  69. .SH DESCRIPTION
  70. .PP
  71. .B s3cmd
  72. is a command line client for copying files to/from
  73. Amazon S3 (Simple Storage Service) and performing other
  74. related tasks, for instance creating and removing buckets,
  75. listing objects, etc.
  76. .SH COMMANDS
  77. .PP
  78. .B s3cmd
  79. can do several \\fIactions\\fR specified by the following \\fIcommands\\fR.
  80. $commands
  81. .PP
  82. Commands for static WebSites configuration
  83. $wscommands
  84. .PP
  85. Commands for CloudFront management
  86. $cfcommands
  87. .SH OPTIONS
  88. .PP
  89. Some of the below specified options can have their default
  90. values set in
  91. .B s3cmd
  92. config file (by default \$HOME/.s3cmd). As it's a simple text file
  93. feel free to open it with your favorite text editor and do any
  94. changes you like.
  95. $options
  96. .SH EXAMPLES
  97. One of the most powerful commands of \\fIs3cmd\\fR is \\fBs3cmd sync\\fR used for
  98. synchronising complete directory trees to or from remote S3 storage. To some extent
  99. \\fBs3cmd put\\fR and \\fBs3cmd get\\fR share a similar behaviour with \\fBsync\\fR.
  100. .PP
  101. Basic usage common in backup scenarios is as simple as:
  102. .nf
  103. s3cmd sync /local/path/ s3://test\\-bucket/backup/
  104. .fi
  105. .PP
  106. This command will find all files under /local/path directory and copy them
  107. to corresponding paths under s3://test\\-bucket/backup on the remote side.
  108. For example:
  109. .nf
  110. /local/path/\\fBfile1.ext\\fR \\-> s3://bucket/backup/\\fBfile1.ext\\fR
  111. /local/path/\\fBdir123/file2.bin\\fR \\-> s3://bucket/backup/\\fBdir123/file2.bin\\fR
  112. .fi
  113. .PP
  114. However if the local path doesn't end with a slash the last directory's name
  115. is used on the remote side as well. Compare these with the previous example:
  116. .nf
  117. s3cmd sync /local/path s3://test\\-bucket/backup/
  118. .fi
  119. will sync:
  120. .nf
  121. /local/\\fBpath/file1.ext\\fR \\-> s3://bucket/backup/\\fBpath/file1.ext\\fR
  122. /local/\\fBpath/dir123/file2.bin\\fR \\-> s3://bucket/backup/\\fBpath/dir123/file2.bin\\fR
  123. .fi
  124. .PP
  125. To retrieve the files back from S3 use inverted syntax:
  126. .nf
  127. s3cmd sync s3://test\\-bucket/backup/ ~/restore/
  128. .fi
  129. that will download files:
  130. .nf
  131. s3://bucket/backup/\\fBfile1.ext\\fR \\-> ~/restore/\\fBfile1.ext\\fR
  132. s3://bucket/backup/\\fBdir123/file2.bin\\fR \\-> ~/restore/\\fBdir123/file2.bin\\fR
  133. .fi
  134. .PP
  135. Without the trailing slash on source the behaviour is similar to
  136. what has been demonstrated with upload:
  137. .nf
  138. s3cmd sync s3://test\\-bucket/backup ~/restore/
  139. .fi
  140. will download the files as:
  141. .nf
  142. s3://bucket/\\fBbackup/file1.ext\\fR \\-> ~/restore/\\fBbackup/file1.ext\\fR
  143. s3://bucket/\\fBbackup/dir123/file2.bin\\fR \\-> ~/restore/\\fBbackup/dir123/file2.bin\\fR
  144. .fi
  145. .PP
  146. All source file names, the bold ones above, are matched against \\fBexclude\\fR
  147. rules and those that match are then re\\-checked against \\fBinclude\\fR rules to see
  148. whether they should be excluded or kept in the source list.
  149. .PP
  150. For the purpose of \\fB\\-\\-exclude\\fR and \\fB\\-\\-include\\fR matching only the
  151. bold file names above are used. For instance only \\fBpath/file1.ext\\fR is tested
  152. against the patterns, not \\fI/local/\\fBpath/file1.ext\\fR
  153. .PP
  154. Both \\fB\\-\\-exclude\\fR and \\fB\\-\\-include\\fR work with shell\\-style wildcards (a.k.a. GLOB).
  155. For a greater flexibility s3cmd provides Regular\\-expression versions of the two exclude options
  156. named \\fB\\-\\-rexclude\\fR and \\fB\\-\\-rinclude\\fR.
  157. The options with ...\\fB\\-from\\fR suffix (eg \\-\\-rinclude\\-from) expect a filename as
  158. an argument. Each line of such a file is treated as one pattern.
  159. .PP
  160. There is only one set of patterns built from all \\fB\\-\\-(r)exclude(\\-from)\\fR options
  161. and similarly for include variant. Any file excluded with eg \\-\\-exclude can
  162. be put back with a pattern found in \\-\\-rinclude\\-from list.
  163. .PP
  164. Run s3cmd with \\fB\\-\\-dry\\-run\\fR to verify that your rules work as expected.
  165. Use together with \\fB\\-\\-debug\\fR get detailed information
  166. about matching file names against exclude and include rules.
  167. .PP
  168. For example to exclude all files with \".jpg\" extension except those beginning with a number use:
  169. .PP
  170. \\-\\-exclude '*.jpg' \\-\\-rinclude '[0\\-9].*\\.jpg'
  171. .PP
  172. To exclude all files except \"*.jpg\" extension, use:
  173. .PP
  174. \\-\\-exclude '*' \\-\\-include '*.jpg'
  175. .PP
  176. To exclude local directory 'somedir', be sure to use a trailing forward slash, as such:
  177. .PP
  178. \\-\\-exclude 'somedir/'
  179. .PP
  180. .SH SEE ALSO
  181. For the most up to date list of options run:
  182. .B s3cmd \\-\\-help
  183. .br
  184. For more info about usage, examples and other related info visit project homepage at:
  185. .B http://s3tools.org
  186. .SH AUTHOR
  187. Written by Michal Ludvig and contributors
  188. .SH CONTACT, SUPPORT
  189. Preferred way to get support is our mailing list:
  190. .br
  191. .I s3tools\\-general\@lists.sourceforge.net
  192. .br
  193. or visit the project homepage:
  194. .br
  195. .B http://s3tools.org
  196. .SH REPORTING BUGS
  197. Report bugs to
  198. .I s3tools\\-bugs\@lists.sourceforge.net
  199. .SH COPYRIGHT
  200. Copyright \\(co 2007\\-2015 TGRMN Software \\- http://www.tgrmn.com \\- and contributors
  201. .br
  202. .SH LICENSE
  203. This program is free software; you can redistribute it and/or modify
  204. it under the terms of the GNU General Public License as published by
  205. the Free Software Foundation; either version 2 of the License, or
  206. (at your option) any later version.
  207. This program is distributed in the hope that it will be useful,
  208. but WITHOUT ANY WARRANTY; without even the implied warranty of
  209. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  210. GNU General Public License for more details.
  211. .br
  212. ";