aboutsummaryrefslogtreecommitdiff
path: root/src/line_accumulator.cc
diff options
context:
space:
mode:
authorAdrian Kummerlaender2016-04-07 16:16:41 +0200
committerAdrian Kummerlaender2016-04-07 16:16:41 +0200
commit8ccbf252e3d3910081de920b2388204e425400c0 (patch)
treebccf24c94efe6c65601ee03fb6e64f052cb65416 /src/line_accumulator.cc
parent43779dc2b4dffdc75b1b6ca90b49b1e24bbea0fb (diff)
downloadjustify-8ccbf252e3d3910081de920b2388204e425400c0.tar
justify-8ccbf252e3d3910081de920b2388204e425400c0.tar.gz
justify-8ccbf252e3d3910081de920b2388204e425400c0.tar.bz2
justify-8ccbf252e3d3910081de920b2388204e425400c0.tar.lz
justify-8ccbf252e3d3910081de920b2388204e425400c0.tar.xz
justify-8ccbf252e3d3910081de920b2388204e425400c0.tar.zst
justify-8ccbf252e3d3910081de920b2388204e425400c0.zip
Implement proper CLI argument handling using `boost::program_options`
Became necessary due to the introduction of custom line offset as an additional user-defined parameter.
Diffstat (limited to 'src/line_accumulator.cc')
-rw-r--r--src/line_accumulator.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/line_accumulator.cc b/src/line_accumulator.cc
index d12ef54..31b8ddc 100644
--- a/src/line_accumulator.cc
+++ b/src/line_accumulator.cc
@@ -54,8 +54,12 @@ std::size_t getCharacterLength(const std::string& token) {
namespace justify {
-LineAccumulator::LineAccumulator(const std::uint8_t max_length):
+LineAccumulator::LineAccumulator(
+ const std::uint8_t max_length,
+ const std::uint8_t offset
+):
max_length_{max_length},
+ offset_{offset},
length_{0},
tokens_{} { }
@@ -160,6 +164,10 @@ void LineAccumulator::discharge(const bool full) {
this->justify();
}
+ if ( this->offset_ > 0 ) {
+ std::cout << std::string(this->offset_, ' ');
+ }
+
for ( const auto& token : this->tokens_ ) {
std::cout << token.first
<< std::string(token.second, ' ');