summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2015-03-13 13:49:02 +0000
committerRichard Hughes <richard@hughsie.com>2015-03-13 13:49:02 +0000
commit35db419b6ef8e9b07036266359ff2edfbacccbc1 (patch)
tree9418ce9674647b8eccff531915e5607d136dd8b6
parent51e3750627dae9a3cef708101ee0afc1ccff3f06 (diff)
downloadappstream-glib-35db419b6ef8e9b07036266359ff2edfbacccbc1.tar.gz
Add --batch-output to be able to disable the progress panel when building
Fixes: https://github.com/hughsie/appstream-glib/issues/35
-rw-r--r--client/as-builder.c6
-rw-r--r--libappstream-builder/asb-context.c4
-rw-r--r--libappstream-builder/asb-context.h2
-rw-r--r--libappstream-builder/asb-panel.c16
-rw-r--r--libappstream-builder/asb-panel.h2
-rw-r--r--libappstream-builder/asb-self-test.c2
6 files changed, 32 insertions, 0 deletions
diff --git a/client/as-builder.c b/client/as-builder.c
index feafe54..d706b4a 100644
--- a/client/as-builder.c
+++ b/client/as-builder.c
@@ -129,6 +129,7 @@ main (int argc, char **argv)
GOptionContext *option_context;
const gchar *filename;
gboolean add_cache_id = FALSE;
+ gboolean batch_output = FALSE;
gboolean embedded_icons = FALSE;
gboolean hidpi_enabled = FALSE;
gboolean include_failed = FALSE;
@@ -183,6 +184,9 @@ main (int argc, char **argv)
{ "uncompressed-icons", '\0', 0, G_OPTION_ARG_NONE, &uncompressed_icons,
/* TRANSLATORS: command line option */
_("Do not compress the icons into a tarball"), NULL },
+ { "batch-output", '\0', 0, G_OPTION_ARG_NONE, &batch_output,
+ /* TRANSLATORS: command line option */
+ _("Do not use escape sequences in terminal output"), NULL },
{ "log-dir", '\0', 0, G_OPTION_ARG_FILENAME, &log_dir,
/* TRANSLATORS: command line option */
_("Set the logging directory"), "DIR" },
@@ -345,6 +349,8 @@ main (int argc, char **argv)
flags |= ASB_CONTEXT_FLAG_INCLUDE_FAILED;
if (uncompressed_icons)
flags |= ASB_CONTEXT_FLAG_UNCOMPRESSED_ICONS;
+ if (batch_output)
+ flags |= ASB_CONTEXT_FLAG_BATCH_OUTPUT;
asb_context_set_flags (ctx, flags);
ret = asb_context_setup (ctx, &error);
diff --git a/libappstream-builder/asb-context.c b/libappstream-builder/asb-context.c
index 9536495..38945e5 100644
--- a/libappstream-builder/asb-context.c
+++ b/libappstream-builder/asb-context.c
@@ -143,6 +143,10 @@ asb_context_set_flags (AsbContext *ctx, AsbContextFlags flags)
as_store_add_metadata_index (priv->store_old, "X-CacheID");
}
priv->flags = flags;
+
+ /* only enable the fancy panel if not in batch mode */
+ asb_panel_set_enabled (priv->panel,
+ (flags & ASB_CONTEXT_FLAG_BATCH_OUTPUT) == 0);
}
/**
diff --git a/libappstream-builder/asb-context.h b/libappstream-builder/asb-context.h
index b847b65..c59dc5c 100644
--- a/libappstream-builder/asb-context.h
+++ b/libappstream-builder/asb-context.h
@@ -69,6 +69,7 @@ struct _AsbContextClass
* @ASB_CONTEXT_FLAG_NO_NETWORK: Do not download files
* @ASB_CONTEXT_FLAG_INCLUDE_FAILED: Write the origin-ignore.xml file
* @ASB_CONTEXT_FLAG_UNCOMPRESSED_ICONS: Do not pack icons into a tarball
+ * @ASB_CONTEXT_FLAG_BATCH_OUTPUT: Do not write escape sequences
*
* The flags to use when processing the context.
**/
@@ -82,6 +83,7 @@ typedef enum {
ASB_CONTEXT_FLAG_NO_NETWORK = 1 << 4, /* Since: 0.3.5 */
ASB_CONTEXT_FLAG_INCLUDE_FAILED = 1 << 5, /* Since: 0.3.5 */
ASB_CONTEXT_FLAG_UNCOMPRESSED_ICONS = 1 << 6, /* Since: 0.3.5 */
+ ASB_CONTEXT_FLAG_BATCH_OUTPUT = 1 << 7, /* Since: 0.3.6 */
/*< private >*/
ASB_CONTEXT_FLAG_LAST,
} AsbContextFlags;
diff --git a/libappstream-builder/asb-panel.c b/libappstream-builder/asb-panel.c
index cb9ae31..6b67a99 100644
--- a/libappstream-builder/asb-panel.c
+++ b/libappstream-builder/asb-panel.c
@@ -364,6 +364,22 @@ asb_panel_set_job_total (AsbPanel *panel, guint job_total)
}
/**
+ * asb_panel_set_enabled:
+ * @panel: A #AsbPanel
+ * @enabled: %TRUE for enabled
+ *
+ * Enables or disables the fancy progress panel.
+ *
+ * Since: 0.3.6
+ **/
+void
+asb_panel_set_enabled (AsbPanel *panel, gboolean enabled)
+{
+ AsbPanelPrivate *priv = GET_PRIVATE (panel);
+ priv->enabled = enabled;
+}
+
+/**
* asb_panel_finalize:
**/
static void
diff --git a/libappstream-builder/asb-panel.h b/libappstream-builder/asb-panel.h
index 602bad2..9839a00 100644
--- a/libappstream-builder/asb-panel.h
+++ b/libappstream-builder/asb-panel.h
@@ -61,6 +61,8 @@ AsbPanel *asb_panel_new (void);
void asb_panel_remove (AsbPanel *panel);
void asb_panel_set_title (AsbPanel *panel,
const gchar *title);
+void asb_panel_set_enabled (AsbPanel *panel,
+ gboolean enabled);
void asb_panel_set_status (AsbPanel *panel,
const gchar *fmt,
...)
diff --git a/libappstream-builder/asb-self-test.c b/libappstream-builder/asb-self-test.c
index 30a5f9b..99104d8 100644
--- a/libappstream-builder/asb-self-test.c
+++ b/libappstream-builder/asb-self-test.c
@@ -333,6 +333,7 @@ asb_test_context_test_func (AsbTestContextMode mode)
asb_context_set_flags (ctx, ASB_CONTEXT_FLAG_ADD_CACHE_ID |
ASB_CONTEXT_FLAG_NO_NETWORK |
ASB_CONTEXT_FLAG_INCLUDE_FAILED |
+ ASB_CONTEXT_FLAG_BATCH_OUTPUT |
ASB_CONTEXT_FLAG_HIDPI_ICONS);
asb_context_set_basename (ctx, "appstream");
asb_context_set_origin (ctx, "asb-self-test");
@@ -853,6 +854,7 @@ asb_test_context_extra_appstream_func (void)
asb_context_set_api_version (ctx, 0.8);
asb_context_set_flags (ctx, ASB_CONTEXT_FLAG_ADD_CACHE_ID |
ASB_CONTEXT_FLAG_NO_NETWORK |
+ ASB_CONTEXT_FLAG_BATCH_OUTPUT |
ASB_CONTEXT_FLAG_HIDPI_ICONS);
asb_context_set_basename (ctx, "appstream");
asb_context_set_origin (ctx, "asb-self-test");