aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2007-10-06 20:09:57 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2007-10-06 20:09:57 +0000
commitd8494ea7e2ec2238cd4a5db24208ba27d051cfc5 (patch)
tree2bb32e263e4b0445e32d1a7b9ec94ba2c0bd872e
parent2f3c62c13c8e0655fc962d49ae9be70f713ba580 (diff)
downloadpaludis-d8494ea7e2ec2238cd4a5db24208ba27d051cfc5.tar.gz
paludis-d8494ea7e2ec2238cd4a5db24208ba27d051cfc5.tar.xz
Improve display of licenses, and remove some extraneous blank lines.
-rw-r--r--src/output/console_query_task.cc54
1 files changed, 48 insertions, 6 deletions
diff --git a/src/output/console_query_task.cc b/src/output/console_query_task.cc
index 8131a07..5939e0a 100644
--- a/src/output/console_query_task.cc
+++ b/src/output/console_query_task.cc
@@ -170,6 +170,45 @@ ConsoleQueryTask::display_versions_by_repository(const PackageDepSpec &,
namespace
{
+ class ComplexLicenseFinder :
+ public ConstVisitor<LicenseSpecTree>,
+ public ConstVisitor<LicenseSpecTree>::VisitConstSequence<ComplexLicenseFinder, AllDepSpec>
+ {
+ private:
+ bool _is_complex;
+
+ public:
+ ComplexLicenseFinder() :
+ _is_complex(false)
+ {
+ }
+
+ using ConstVisitor<LicenseSpecTree>::VisitConstSequence<ComplexLicenseFinder, AllDepSpec>::visit_sequence;
+
+ void visit_leaf(const LicenseDepSpec &)
+ {
+ }
+
+ void visit_sequence(const AnyDepSpec &,
+ LicenseSpecTree::ConstSequenceIterator,
+ LicenseSpecTree::ConstSequenceIterator)
+ {
+ _is_complex = true;
+ }
+
+ void visit_sequence(const UseDepSpec &,
+ LicenseSpecTree::ConstSequenceIterator,
+ LicenseSpecTree::ConstSequenceIterator)
+ {
+ _is_complex = true;
+ }
+
+ operator bool () const
+ {
+ return _is_complex;
+ }
+ };
+
class Displayer :
public ConstVisitor<MetadataKeyVisitorTypes>
{
@@ -276,7 +315,6 @@ namespace
task->output_left_column(k.human_name() + ":");
task->output_right_column("");
task->output_stream() << k.pretty_print(formatter);
- task->output_endl();
}
}
}
@@ -332,9 +370,15 @@ namespace
else
{
task->output_left_column(k.human_name() + ":");
- task->output_right_column("");
- task->output_stream() << k.pretty_print(formatter);
- task->output_endl();
+ ComplexLicenseFinder is_complex;
+ k.value()->accept(is_complex);
+ if (is_complex)
+ {
+ task->output_right_column("");
+ task->output_stream() << k.pretty_print(formatter);
+ }
+ else
+ task->output_right_column(k.pretty_print_flat(formatter));
}
}
}
@@ -354,7 +398,6 @@ namespace
task->output_left_column(k.human_name() + ":");
task->output_right_column("");
task->output_stream() << k.pretty_print(formatter);
- task->output_endl();
}
}
}
@@ -374,7 +417,6 @@ namespace
task->output_left_column(k.human_name() + ":");
task->output_right_column("");
task->output_stream() << k.pretty_print(formatter);
- task->output_endl();
}
}
}