MCPcopy Index your code
hub / github.com/git/git / usage_with_options_internal

Function usage_with_options_internal

parse-options.c:1314–1480  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1312}
1313
1314static enum parse_opt_result usage_with_options_internal(struct parse_opt_ctx_t *ctx,
1315 const char * const *usagestr,
1316 const struct option *opts,
1317 int full, int err)
1318{
1319 const struct option *all_opts = opts;
1320 FILE *outfile = err ? stderr : stdout;
1321 int need_newline;
1322
1323 const char *usage_prefix = _("usage: %s");
1324 /*
1325 * The translation could be anything, but we can count on
1326 * msgfmt(1)'s --check option to have asserted that "%s" is in
1327 * the translation. So compute the length of the "usage: "
1328 * part. We are assuming that the translator wasn't overly
1329 * clever and used e.g. "%1$s" instead of "%s", there's only
1330 * one "%s" in "usage_prefix" above, so there's no reason to
1331 * do so even with a RTL language.
1332 */
1333 size_t usage_len = strlen(usage_prefix) - strlen("%s");
1334 /*
1335 * TRANSLATORS: the colon here should align with the
1336 * one in "usage: %s" translation.
1337 */
1338 const char *or_prefix = _(" or: %s");
1339 /*
1340 * TRANSLATORS: You should only need to translate this format
1341 * string if your language is a RTL language (e.g. Arabic,
1342 * Hebrew etc.), not if it's a LTR language (e.g. German,
1343 * Russian, Chinese etc.).
1344 *
1345 * When a translated usage string has an embedded "\n" it's
1346 * because options have wrapped to the next line. The line
1347 * after the "\n" will then be padded to align with the
1348 * command name, such as N_("git cmd [opt]\n<8
1349 * spaces>[opt2]"), where the 8 spaces are the same length as
1350 * "git cmd ".
1351 *
1352 * This format string prints out that already-translated
1353 * line. The "%*s" is whitespace padding to account for the
1354 * padding at the start of the line that we add in this
1355 * function. The "%s" is a line in the (hopefully already
1356 * translated) N_() usage string, which contained embedded
1357 * newlines before we split it up.
1358 */
1359 const char *usage_continued = _("%*s%s");
1360 const char *prefix = usage_prefix;
1361 int saw_empty_line = 0;
1362
1363 parse_options_check_harder(opts);
1364
1365 if (!usagestr)
1366 return PARSE_OPT_HELP;
1367
1368 if (!err && ctx && ctx->flags & PARSE_OPT_SHELL_EVAL)
1369 fprintf(outfile, "cat <<\\EOF\n");
1370
1371 while (*usagestr) {

Callers 3

parse_options_stepFunction · 0.85
usage_with_optionsFunction · 0.85

Calls 9

string_list_splitFunction · 0.85
fprintf_lnFunction · 0.85
string_list_clearFunction · 0.85
usage_indentFunction · 0.85
utf8_fprintfFunction · 0.85
usage_arghFunction · 0.85
usage_paddingFunction · 0.85
find_option_by_long_nameFunction · 0.85

Tested by

no test coverage detected