Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Add new %Od and %OD pkg_printf() format codes for option default value and option description, respectively.
Matthew Seaman committed 12 years ago
commit efbb19dcec91461f12f731f62a2a1f33aeecacc2
parent 6c27196
3 files changed +54 -0
modified libpkg/pkg_printf.3
@@ -598,6 +598,14 @@ Option name [string]
.It Cm %Ov
Option value [string]
.Vt struct pkg_option *
+
.It Cm %Od
+
Option default value [string] (if known: will produce an empty string
+
if not.)
+
.Vt struct pkg_option *
+
.It Cm %OD
+
Option description [string] (if known: will produce an empty string
+
if not.)
+
.Vt struct pkg_option *
.It Cm \^%R
Repository path - the path relative to the repository root that
package may be downloaded from [string].
modified libpkg/pkg_printf.c
@@ -91,6 +91,8 @@
 * O  pkg          List of options
 * On pkg_option   Option name (key)
 * Ov pkg_option   Option value
+
 * Od pkg_option   Option default value (if known)
+
 * OD pkg_option   Option description
 *
 * P
 * Q
@@ -450,6 +452,24 @@ static const struct pkg_printf_fmt fmt[] = {
		PP_PKG|PP_O,
		&format_option_value,
	},
+
	[PP_PKG_OPTION_DEFAULT] =
+
	{
+
		'O',
+
		'd',
+
		false,
+
		false,
+
		PP_PKG|PP_O,
+
		&format_option_default,
+
	},
+
	[PP_PKG_OPTION_DESCRIPTION] =
+
	{
+
		'O',
+
		'D',
+
		false,
+
		false,
+
		PP_PKG|PP_O,
+
		&format_option_description,
+
	},
	[PP_PKG_OPTIONS] =
	{
		'O',
@@ -1331,6 +1351,28 @@ format_option_value(struct sbuf *sbuf, const void *data, struct percent_esc *p)
}

/*
+
 * %Od -- Option default value.
+
 */
+
struct sbuf *
+
format_option_default(struct sbuf *sbuf, const void *data, struct percent_esc *p)
+
{
+
	const struct pkg_option	*option = data;
+

+
	return (string_val(sbuf, pkg_option_default_value(option), p));
+
}
+

+
/*
+
 * %OD -- Option description
+
 */
+
struct sbuf *
+
format_option_description(struct sbuf *sbuf, const void *data, struct percent_esc *p)
+
{
+
	const struct pkg_option	*option = data;
+

+
	return (string_val(sbuf, pkg_option_description(option), p));
+
}
+

+
/*
 * %R -- Repo path. string.
 */
struct sbuf *
modified libpkg/private/pkg_printf.h
@@ -105,6 +105,8 @@ typedef enum _fmt_code_t {
	PP_PKG_REPO_IDENT,
	PP_PKG_OPTION_NAME,
	PP_PKG_OPTION_VALUE,
+
	PP_PKG_OPTION_DEFAULT,
+
	PP_PKG_OPTION_DESCRIPTION,
	PP_PKG_OPTIONS,
	PP_PKG_REPO_PATH,
	PP_PKG_CHAR_STRING,
@@ -191,6 +193,8 @@ _static struct sbuf *format_repo_ident(struct sbuf *, const void *, struct perce
_static struct sbuf *format_options(struct sbuf *, const void *, struct percent_esc *);
_static struct sbuf *format_option_name(struct sbuf *, const void *, struct percent_esc *);
_static struct sbuf *format_option_value(struct sbuf *, const void *, struct percent_esc *);
+
_static struct sbuf *format_option_default(struct sbuf *, const void *, struct percent_esc *);
+
_static struct sbuf *format_option_description(struct sbuf *, const void *, struct percent_esc *);
_static struct sbuf *format_repo_path(struct sbuf *, const void *, struct percent_esc *);
_static struct sbuf *format_char_string(struct sbuf *, const void *, struct percent_esc *);
_static struct sbuf *format_users(struct sbuf *, const void *, struct percent_esc *);