Commit b123c2fd authored by Zeeshan Ali's avatar Zeeshan Ali

gst-inspect: Colored output

parent 7844e3ea
......@@ -7,7 +7,7 @@ extern crate glib_sys as glib_ffi;
extern crate colored;
extern crate nix;
use colored::Colorize;
use colored::{ColoredString, Colorize};
mod piped_stdio;
......@@ -25,7 +25,6 @@ fn main() {
};
if let Err(e) = gst::init() {
// FIXME: Color output
print_error(e, "Error initializing GStreamer");
std::process::exit(-1);
......@@ -61,14 +60,23 @@ fn print_element_list(print_all: bool) {
print_element_info(&feature, true);
} else if let Some(metadata) = factory.get_metadata(&gst::ELEMENT_METADATA_LONGNAME)
{
println!("{}: {}: {}", name, factory.get_name(), metadata);
println!(
"{}: {}: {}",
plugin_name_color(&name),
element_name_color(&factory.get_name()),
element_detail_color(&metadata)
);
}
} else if let Some(factory) = feature.downcast_ref::<gst::TypeFindFactory>() {
if print_all {
continue;
}
print!("{}: {}: ", name, factory.get_name());
print!(
"{}: {}: ",
plugin_name_color(&name),
element_name_color(&factory.get_name())
);
let extensions = factory.get_extensions();
if extensions.len() != 0 {
let mut i = 0;
......@@ -77,41 +85,56 @@ fn print_element_list(print_all: bool) {
if i != 0 {
print!(", ");
}
print!("{}", extension);
print!("{}", element_detail_color(&extension));
i = i + 1;
}
println!("");
} else {
println!("no extensions");
println!("{}", element_detail_color("no extensions"));
}
} else {
if !print_all {
println!("{}: {}: {}", name, feature.get_name(), feature.get_type());
println!(
"{}: {}: {}",
plugin_name_color(&name),
element_name_color(&feature.get_name()),
element_detail_color(&feature.get_type().to_string())
);
}
}
}
}
print!("\nTotal count: {} plugins", plugins.len());
print!(
"\n{}: {}",
prop_name_color("Total count"),
prop_value_color(&format!("{} plugins", plugins.len()))
);
if n_blacklisted != 0 {
print!(
" ({} blacklisted {} not shown)",
n_blacklisted,
if n_blacklisted > 1 {
"entries"
} else {
"entry"
}
"{}",
prop_value_color(&format!(
" ({} blacklisted {} not shown)",
n_blacklisted,
if n_blacklisted > 1 {
"entries"
} else {
"entry"
}
))
);
}
println!(
", {} {}",
n_features,
if n_features > 1 {
"features"
} else {
"feature"
}
", {}",
prop_value_color(&format!(
"{} {}",
n_features,
if n_features > 1 {
"features"
} else {
"feature"
}
))
);
}
......@@ -119,6 +142,26 @@ fn print_element_info(_feature: &gst::PluginFeature, _print_names: bool) {
// FIXME: Implement.
}
fn prop_name_color(name: &str) -> ColoredString {
name.cyan()
}
fn prop_value_color(value: &str) -> ColoredString {
value.bright_blue()
}
fn plugin_name_color(name: &str) -> ColoredString {
name.blue()
}
fn element_name_color(name: &str) -> ColoredString {
name.green()
}
fn element_detail_color(detail: &str) -> ColoredString {
detail.white().dimmed()
}
fn get_plugin_flags(plugin: &gst::Plugin) -> gst::PluginFlags {
unsafe {
use glib::translate::{from_glib, ToGlibPtr};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment