CmdUDAs: Migrated from ViewText to Table

This commit is contained in:
Paul Beckingham 2016-10-16 22:53:48 -04:00
parent 6ad736346f
commit 6345b0c7de

View file

@ -26,11 +26,11 @@
#include <cmake.h> #include <cmake.h>
#include <CmdUDAs.h> #include <CmdUDAs.h>
#include <Table.h>
#include <sstream> #include <sstream>
#include <algorithm> #include <algorithm>
#include <Context.h> #include <Context.h>
#include <Filter.h> #include <Filter.h>
#include <ViewText.h>
#include <main.h> #include <main.h>
#include <text.h> #include <text.h>
#include <util.h> #include <util.h>
@ -83,19 +83,19 @@ int CmdUDAs::execute (std::string& output)
// Render a list of UDA name, type, label, allowed values, // Render a list of UDA name, type, label, allowed values,
// possible default value, and finally the usage count. // possible default value, and finally the usage count.
ViewText view; Table table;
view.width (context.getWidth ()); table.width (context.getWidth ());
view.add (Column::factory ("string", STRING_COLUMN_LABEL_UDA)); table.add (STRING_COLUMN_LABEL_UDA);
view.add (Column::factory ("string", STRING_COLUMN_LABEL_TYPE)); table.add (STRING_COLUMN_LABEL_TYPE);
view.add (Column::factory ("string", STRING_COLUMN_LABEL_LABEL)); table.add (STRING_COLUMN_LABEL_LABEL);
view.add (Column::factory ("string", STRING_COLUMN_LABEL_VALUES)); table.add (STRING_COLUMN_LABEL_VALUES);
view.add (Column::factory ("string", STRING_COLUMN_LABEL_DEFAULT)); table.add (STRING_COLUMN_LABEL_DEFAULT);
view.add (Column::factory ("string", STRING_COLUMN_LABEL_UDACOUNT)); table.add (STRING_COLUMN_LABEL_UDACOUNT);
if (context.color ()) if (context.color ())
{ {
Color label (context.config.get ("color.label")); Color label ("underline " + context.config.get ("color.label"));
view.colorHeader (label); table.colorHeader (label);
} }
for (auto& uda : udas) for (auto& uda : udas)
@ -113,17 +113,17 @@ int CmdUDAs::execute (std::string& output)
if (i.has (uda)) if (i.has (uda))
++count; ++count;
int row = view.addRow (); int row = table.addRow ();
view.set (row, 0, uda); table.set (row, 0, uda);
view.set (row, 1, type); table.set (row, 1, type);
view.set (row, 2, label); table.set (row, 2, label);
view.set (row, 3, values); table.set (row, 3, values);
view.set (row, 4, defval); table.set (row, 4, defval);
view.set (row, 5, count); table.set (row, 5, count);
} }
out << optionalBlankLine () out << optionalBlankLine ()
<< view.render () << table.render ()
<< optionalBlankLine () << optionalBlankLine ()
<< (udas.size () == 1 << (udas.size () == 1
? format (STRING_CMD_UDAS_SUMMARY, udas.size ()) ? format (STRING_CMD_UDAS_SUMMARY, udas.size ())
@ -149,26 +149,26 @@ int CmdUDAs::execute (std::string& output)
if (orphans.size ()) if (orphans.size ())
{ {
// Display the orphans and their counts. // Display the orphans and their counts.
ViewText orphanView; Table orphanTable;
orphanView.width (context.getWidth ()); orphanTable.width (context.getWidth ());
orphanView.add (Column::factory ("string", STRING_COLUMN_LABEL_ORPHAN)); orphanTable.add (STRING_COLUMN_LABEL_ORPHAN);
orphanView.add (Column::factory ("string", STRING_COLUMN_LABEL_UDACOUNT)); orphanTable.add (STRING_COLUMN_LABEL_UDACOUNT);
if (context.color ()) if (context.color ())
{ {
Color label (context.config.get ("color.label")); Color label ("underline " + context.config.get ("color.label"));
orphanView.colorHeader (label); orphanTable.colorHeader (label);
} }
for (auto& o : orphans) for (auto& o : orphans)
{ {
int row = orphanView.addRow (); int row = orphanTable.addRow ();
orphanView.set (row, 0, o.first); orphanTable.set (row, 0, o.first);
orphanView.set (row, 1, o.second); orphanTable.set (row, 1, o.second);
} }
out << optionalBlankLine () out << optionalBlankLine ()
<< orphanView.render () << orphanTable.render ()
<< optionalBlankLine () << optionalBlankLine ()
<< (udas.size () == 1 << (udas.size () == 1
? format (STRING_CMD_UDAS_ORPHAN, orphans.size ()) ? format (STRING_CMD_UDAS_ORPHAN, orphans.size ())