Skip to content

Commit d70880d

Browse files
authored
bin: fix help text alignment (#3425)
Signed-off-by: Lionel Cons <[email protected]>
1 parent 341d2ed commit d70880d

File tree

1 file changed

+40
-36
lines changed

1 file changed

+40
-36
lines changed

src/fluent-bit.c

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,13 @@ struct flb_stacktrace flb_st;
7676
#define PLUGIN_OUTPUT 1
7777
#define PLUGIN_FILTER 2
7878

79-
#define get_key(a, b, c) mk_rconf_section_get_key(a, b, c)
80-
#define n_get_key(a, b, c) (intptr_t) get_key(a, b, c)
81-
#define s_get_key(a, b, c) (char *) get_key(a, b, c)
79+
#define print_opt(a, b) printf(" %-24s%s\n", a, b)
80+
#define print_opt_i(a, b, c) printf(" %-24s%s (default: %i)\n", a, b, c)
81+
#define print_opt_s(a, b, c) printf(" %-24s%s (default: %s)\n", a, b, c)
82+
83+
#define get_key(a, b, c) mk_rconf_section_get_key(a, b, c)
84+
#define n_get_key(a, b, c) (intptr_t) get_key(a, b, c)
85+
#define s_get_key(a, b, c) (char *) get_key(a, b, c)
8286

8387
static void flb_version()
8488
{
@@ -108,46 +112,46 @@ static void flb_help(int rc, struct flb_config *config)
108112

109113
printf("Usage: fluent-bit [OPTION]\n\n");
110114
printf("%sAvailable Options%s\n", ANSI_BOLD, ANSI_RESET);
111-
printf(" -b --storage_path=PATH\tspecify a storage buffering path\n");
112-
printf(" -c --config=FILE\tspecify an optional configuration file\n");
113-
printf(" -D, --dry-run\tdry run\n");
115+
print_opt("-b --storage_path=PATH", "specify a storage buffering path");
116+
print_opt("-c --config=FILE", "specify an optional configuration file");
114117
#ifdef FLB_HAVE_FORK
115-
printf(" -d, --daemon\t\trun Fluent Bit in background mode\n");
118+
print_opt("-d, --daemon", "run Fluent Bit in background mode");
116119
#endif
117-
printf(" -f, --flush=SECONDS\tflush timeout in seconds (default: %i)\n",
118-
FLB_CONFIG_FLUSH_SECS);
119-
printf(" -F --filter=FILTER\t set a filter\n");
120-
printf(" -i, --input=INPUT\tset an input\n");
121-
printf(" -m, --match=MATCH\tset plugin match, same as '-p match=abc'\n");
122-
printf(" -o, --output=OUTPUT\tset an output\n");
123-
printf(" -p, --prop=\"A=B\"\tset plugin configuration property\n");
120+
print_opt("-D, --dry-run", "dry run");
121+
print_opt_i("-f, --flush=SECONDS", "flush timeout in seconds",
122+
FLB_CONFIG_FLUSH_SECS);
123+
print_opt("-F --filter=FILTER", "set a filter");
124+
print_opt("-i, --input=INPUT", "set an input");
125+
print_opt("-m, --match=MATCH", "set plugin match, same as '-p match=abc'");
126+
print_opt("-o, --output=OUTPUT", "set an output");
127+
print_opt("-p, --prop=\"A=B\"", "set plugin configuration property");
124128
#ifdef FLB_HAVE_PARSER
125-
printf(" -R, --parser=FILE\tspecify a parser configuration file\n");
129+
print_opt("-R, --parser=FILE", "specify a parser configuration file");
126130
#endif
127-
printf(" -e, --plugin=FILE\tload an external plugin (shared lib)\n");
128-
printf(" -l, --log_file=FILE\twrite log info to a file\n");
129-
printf(" -t, --tag=TAG\t\tset plugin tag, same as '-p tag=abc'\n");
131+
print_opt("-e, --plugin=FILE", "load an external plugin (shared lib)");
132+
print_opt("-l, --log_file=FILE", "write log info to a file");
133+
print_opt("-t, --tag=TAG", "set plugin tag, same as '-p tag=abc'");
130134
#ifdef FLB_HAVE_STREAM_PROCESSOR
131-
printf(" -T, --sp-task=SQL\tdefine a stream processor task\n");
135+
print_opt("-T, --sp-task=SQL", "define a stream processor task");
132136
#endif
133-
printf(" -v, --verbose\t\tincrease logging verbosity (default: info)\n");
137+
print_opt("-v, --verbose", "increase logging verbosity (default: info)");
134138
#ifdef FLB_HAVE_TRACE
135-
printf(" -vv\t\t\ttrace mode (available)\n");
139+
print_opt("-vv", "trace mode (available)");
136140
#endif
137-
printf(" -w, --workdir\t\tset the working directory\n");
141+
print_opt("-w, --workdir", "set the working directory");
138142
#ifdef FLB_HAVE_HTTP_SERVER
139-
printf(" -H, --http\t\tenable monitoring HTTP server\n");
140-
printf(" -P, --port\t\tset HTTP server TCP port (default: %s)\n",
141-
FLB_CONFIG_HTTP_PORT);
143+
print_opt("-H, --http", "enable monitoring HTTP server");
144+
print_opt_s("-P, --port", "set HTTP server TCP port",
145+
FLB_CONFIG_HTTP_PORT);
142146
#endif
143-
printf(" -s, --coro_stack_size\tSet coroutines stack size in bytes "
144-
"(default: %i)\n", config->coro_stack_size);
145-
printf(" -q, --quiet\t\tquiet mode\n");
146-
printf(" -S, --sosreport\tsupport report for Enterprise customers\n");
147-
printf(" -V, --version\t\tshow version number\n");
148-
printf(" -h, --help\t\tprint this help\n\n");
147+
print_opt_i("-s, --coro_stack_size", "set coroutines stack size in bytes",
148+
config->coro_stack_size);
149+
print_opt("-q, --quiet", "quiet mode");
150+
print_opt("-S, --sosreport", "support report for Enterprise customers");
151+
print_opt("-V, --version", "show version number");
152+
print_opt("-h, --help", "print this help");
149153

150-
printf("%sInputs%s\n", ANSI_BOLD, ANSI_RESET);
154+
printf("\n%sInputs%s\n", ANSI_BOLD, ANSI_RESET);
151155

152156
/* Iterate each supported input */
153157
mk_list_foreach(head, &config->in_plugins) {
@@ -156,13 +160,13 @@ static void flb_help(int rc, struct flb_config *config)
156160
/* useless..., just skip it. */
157161
continue;
158162
}
159-
printf(" %-22s%s\n", in->name, in->description);
163+
print_opt(in->name, in->description);
160164
}
161165

162166
printf("\n%sFilters%s\n", ANSI_BOLD, ANSI_RESET);
163167
mk_list_foreach(head, &config->filter_plugins) {
164168
filter = mk_list_entry(head, struct flb_filter_plugin, _head);
165-
printf(" %-22s%s\n", filter->name, filter->description);
169+
print_opt(filter->name, filter->description);
166170
}
167171

168172
printf("\n%sOutputs%s\n", ANSI_BOLD, ANSI_RESET);
@@ -172,12 +176,12 @@ static void flb_help(int rc, struct flb_config *config)
172176
/* useless..., just skip it. */
173177
continue;
174178
}
175-
printf(" %-22s%s\n", out->name, out->description);
179+
print_opt(out->name, out->description);
176180
}
177181

178182
printf("\n%sInternal%s\n", ANSI_BOLD, ANSI_RESET);
179183
printf(" Event Loop = %s\n", mk_event_backend());
180-
printf(" Build Flags = %s\n", FLB_INFO_FLAGS);
184+
printf(" Build Flags =%s\n", FLB_INFO_FLAGS);
181185
exit(rc);
182186
}
183187

0 commit comments

Comments
 (0)