Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdd7c60f

Browse files
committed
Introduce long options in pg_archivecleanup
This patch is a preliminary refactoring for an upcoming patch aimed atadding new options to this tool, and using long options for these ismore user-friendly. The existing short options gain long flavors, asof:* -d/--debug* -n/--dry-run* -x/--strip-extensionAuthor: Atsushi TorikoshiReviewed-by: Fujii Masao, Kyotaro Horiguchi, Michael PaquierDiscussion:https://postgr.es/m/d660ef741ce3d82f3b4283f1cafd576c@oss.nttdata.com
1 parentcfc43ae commitdd7c60f

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

‎doc/src/sgml/ref/pgarchivecleanup.sgml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ pg_archivecleanup: removing file "archive/00000001000000370000000E"
9595

9696
<varlistentry>
9797
<term><option>-d</option></term>
98+
<term><option>--debug</option></term>
9899
<listitem>
99100
<para>
100101
Print lots of debug logging output on <filename>stderr</filename>.
@@ -104,6 +105,7 @@ pg_archivecleanup: removing file "archive/00000001000000370000000E"
104105

105106
<varlistentry>
106107
<term><option>-n</option></term>
108+
<term><option>--dry-run</option></term>
107109
<listitem>
108110
<para>
109111
Print the names of the files that would have been removed on <filename>stdout</filename> (performs a dry run).
@@ -122,7 +124,8 @@ pg_archivecleanup: removing file "archive/00000001000000370000000E"
122124
</varlistentry>
123125

124126
<varlistentry>
125-
<term><option>-x</option> <replaceable>extension</replaceable></term>
127+
<term><option>-x <replaceable class="parameter">extension</replaceable></option></term>
128+
<term><option>--strip-extension=<replaceable class="parameter">extension</replaceable></option></term>
126129
<listitem>
127130
<para>
128131
Provide an extension

‎src/bin/pg_archivecleanup/pg_archivecleanup.c

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#include"access/xlog_internal.h"
1919
#include"common/logging.h"
20-
#include"pg_getopt.h"
20+
#include"getopt_long.h"
2121

2222
constchar*progname;
2323

@@ -252,11 +252,13 @@ usage(void)
252252
printf(_("Usage:\n"));
253253
printf(_(" %s [OPTION]... ARCHIVELOCATION OLDESTKEPTWALFILE\n"),progname);
254254
printf(_("\nOptions:\n"));
255-
printf(_(" -d generate debug output (verbose mode)\n"));
256-
printf(_(" -n dry run, show the names of the files that would be removed\n"));
257-
printf(_(" -V, --version output version information, then exit\n"));
258-
printf(_(" -x EXT clean up files if they have this extension\n"));
259-
printf(_(" -?, --help show this help, then exit\n"));
255+
printf(_(" -d, --debug generate debug output (verbose mode)\n"));
256+
printf(_(" -n, --dry-run dry run, show the names of the files that would be\n"
257+
" removed\n"));
258+
printf(_(" -V, --version output version information, then exit\n"));
259+
printf(_(" -x, --strip-extension=EXT strip this extention before identifying files for\n"
260+
" clean up\n"));
261+
printf(_(" -?, --help show this help, then exit\n"));
260262
printf(_("\n"
261263
"For use as archive_cleanup_command in postgresql.conf:\n"
262264
" archive_cleanup_command = 'pg_archivecleanup [OPTION]... ARCHIVELOCATION %%r'\n"
@@ -274,6 +276,12 @@ usage(void)
274276
int
275277
main(intargc,char**argv)
276278
{
279+
staticstructoptionlong_options[]= {
280+
{"debug",no_argument,NULL,'d'},
281+
{"dry-run",no_argument,NULL,'n'},
282+
{"strip-extension",required_argument,NULL,'x'},
283+
{NULL,0,NULL,0}
284+
};
277285
intc;
278286

279287
pg_logging_init(argv[0]);
@@ -294,7 +302,7 @@ main(int argc, char **argv)
294302
}
295303
}
296304

297-
while ((c=getopt(argc,argv,"dnx:"))!=-1)
305+
while ((c=getopt_long(argc,argv,"dnx:",long_options,NULL))!=-1)
298306
{
299307
switch (c)
300308
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp