1 // Copyright (c) 2008, Google Inc.
2 // All rights reserved.
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the
14 // * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 // Author: Dave Nicponski
33 // Bash-style command line flag completion for C++ binaries
35 // This module implements bash-style completions. It achieves this
36 // goal in the following broad chunks:
38 // 1) Take a to-be-completed word, and examine it for search hints
39 // 2) Identify all potentially matching flags
40 // 2a) If there are no matching flags, do nothing.
41 // 2b) If all matching flags share a common prefix longer than the
42 // completion word, output just that matching prefix
43 // 3) Categorize those flags to produce a rough ordering of relevence.
44 // 4) Potentially trim the set of flags returned to a smaller number
45 // that bash is happier with
46 // 5) Output the matching flags in groups ordered by relevence.
47 // 5a) Force bash to place most-relevent groups at the top of the list
48 // 5b) Trim most flag's descriptions to fit on a single terminal line
59 #include "gflags/gflags.h"
65 #ifndef PATH_SEPARATOR
66 #define PATH_SEPARATOR '/'
69 DEFINE_string(tab_completion_word, "",
70 "If non-empty, HandleCommandLineCompletions() will hijack the "
71 "process and attempt to do bash-style command line flag "
72 "completion on this value.");
73 DEFINE_int32(tab_completion_columns, 80,
74 "Number of columns to use in output for tab completion");
76 _START_GOOGLE_NAMESPACE_
80 // Function prototypes and Type forward declarations. Code may be
81 // more easily understood if it is roughly ordered according to
82 // control flow, rather than by C's "declare before use" ordering
83 struct CompletionOptions;
86 // The entry point if flag completion is to be used.
87 static void PrintFlagCompletionInfo(void);
90 // 1) Examine search word
91 static void CanonicalizeCursorWordAndSearchOptions(
92 const string &cursor_word,
93 string *canonical_search_token,
94 CompletionOptions *options);
96 static bool RemoveTrailingChar(string *str, char c);
99 // 2) Find all matches
100 static void FindMatchingFlags(
101 const vector<CommandLineFlagInfo> &all_flags,
102 const CompletionOptions &options,
103 const string &match_token,
104 set<const CommandLineFlagInfo *> *all_matches,
105 string *longest_common_prefix);
107 static bool DoesSingleFlagMatch(
108 const CommandLineFlagInfo &flag,
109 const CompletionOptions &options,
110 const string &match_token);
113 // 3) Categorize matches
114 static void CategorizeAllMatchingFlags(
115 const set<const CommandLineFlagInfo *> &all_matches,
116 const string &search_token,
117 const string &module,
118 const string &package_dir,
119 NotableFlags *notable_flags);
121 static void TryFindModuleAndPackageDir(
122 const vector<CommandLineFlagInfo> all_flags,
124 string *package_dir);
127 // 4) Decide which flags to use
128 static void FinalizeCompletionOutput(
129 const set<const CommandLineFlagInfo *> &matching_flags,
130 CompletionOptions *options,
131 NotableFlags *notable_flags,
132 vector<string> *completions);
134 static void RetrieveUnusedFlags(
135 const set<const CommandLineFlagInfo *> &matching_flags,
136 const NotableFlags ¬able_flags,
137 set<const CommandLineFlagInfo *> *unused_flags);
141 static void OutputSingleGroupWithLimit(
142 const set<const CommandLineFlagInfo *> &group,
143 const string &line_indentation,
144 const string &header,
145 const string &footer,
146 bool long_output_format,
147 int *remaining_line_limit,
148 size_t *completion_elements_added,
149 vector<string> *completions);
152 static string GetShortFlagLine(
153 const string &line_indentation,
154 const CommandLineFlagInfo &info);
156 static string GetLongFlagLine(
157 const string &line_indentation,
158 const CommandLineFlagInfo &info);
164 // Try to deduce the intentions behind this completion attempt. Return the
165 // canonical search term in 'canonical_search_token'. Binary search options
166 // are returned in the various booleans, which should all have intuitive
167 // semantics, possibly except:
168 // - return_all_matching_flags: Generally, we'll trim the number of
169 // returned candidates to some small number, showing those that are
170 // most likely to be useful first. If this is set, however, the user
171 // really does want us to return every single flag as an option.
172 // - force_no_update: Any time we output lines, all of which share a
173 // common prefix, bash will 'helpfully' not even bother to show the
174 // output, instead changing the current word to be that common prefix.
175 // If it's clear this shouldn't happen, we'll set this boolean
176 struct CompletionOptions {
177 bool flag_name_substring_search;
178 bool flag_location_substring_search;
179 bool flag_description_substring_search;
180 bool return_all_matching_flags;
181 bool force_no_update;
184 // Notable flags are flags that are special or preferred for some
185 // reason. For example, flags that are defined in the binary's module
186 // are expected to be much more relevent than flags defined in some
187 // other random location. These sets are specified roughly in precedence
188 // order. Once a flag is placed in one of these 'higher' sets, it won't
189 // be placed in any of the 'lower' sets.
190 struct NotableFlags {
191 typedef set<const CommandLineFlagInfo *> FlagSet;
192 FlagSet perfect_match_flag;
193 FlagSet module_flags; // Found in module file
194 FlagSet package_flags; // Found in same directory as module file
195 FlagSet most_common_flags; // One of the XXX most commonly supplied flags
196 FlagSet subpackage_flags; // Found in subdirectories of package
201 // Tab completion implementation - entry point
202 static void PrintFlagCompletionInfo(void) {
203 string cursor_word = FLAGS_tab_completion_word;
204 string canonical_token;
205 CompletionOptions options;
206 CanonicalizeCursorWordAndSearchOptions(
211 //VLOG(1) << "Identified canonical_token: '" << canonical_token << "'";
213 vector<CommandLineFlagInfo> all_flags;
214 set<const CommandLineFlagInfo *> matching_flags;
215 GetAllFlags(&all_flags);
216 //VLOG(2) << "Found " << all_flags.size() << " flags overall";
218 string longest_common_prefix;
224 &longest_common_prefix);
225 //VLOG(1) << "Identified " << matching_flags.size() << " matching flags";
226 //VLOG(1) << "Identified " << longest_common_prefix
227 // << " as longest common prefix.";
228 if (longest_common_prefix.size() > canonical_token.size()) {
229 // There's actually a shared common prefix to all matching flags,
230 // so may as well output that and quit quickly.
231 //VLOG(1) << "The common prefix '" << longest_common_prefix
232 // << "' was longer than the token '" << canonical_token
233 // << "'. Returning just this prefix for completion.";
234 fprintf(stdout, "--%s", longest_common_prefix.c_str());
237 if (matching_flags.empty()) {
238 //VLOG(1) << "There were no matching flags, returning nothing.";
244 TryFindModuleAndPackageDir(all_flags, &module, &package_dir);
245 //VLOG(1) << "Identified module: '" << module << "'";
246 //VLOG(1) << "Identified package_dir: '" << package_dir << "'";
248 NotableFlags notable_flags;
249 CategorizeAllMatchingFlags(
255 //VLOG(2) << "Categorized matching flags:";
256 //VLOG(2) << " perfect_match: " << notable_flags.perfect_match_flag.size();
257 //VLOG(2) << " module: " << notable_flags.module_flags.size();
258 //VLOG(2) << " package: " << notable_flags.package_flags.size();
259 //VLOG(2) << " most common: " << notable_flags.most_common_flags.size();
260 //VLOG(2) << " subpackage: " << notable_flags.subpackage_flags.size();
262 vector<string> completions;
263 FinalizeCompletionOutput(
269 if (options.force_no_update)
270 completions.push_back("~");
272 //VLOG(1) << "Finalized with " << completions.size()
273 // << " chosen completions";
275 for (vector<string>::const_iterator it = completions.begin();
276 it != completions.end();
278 //VLOG(9) << " Completion entry: '" << *it << "'";
279 fprintf(stdout, "%s\n", it->c_str());
284 // 1) Examine search word (and helper method)
285 static void CanonicalizeCursorWordAndSearchOptions(
286 const string &cursor_word,
287 string *canonical_search_token,
288 CompletionOptions *options) {
289 *canonical_search_token = cursor_word;
290 if (canonical_search_token->empty()) return;
292 // Get rid of leading quotes and dashes in the search term
293 if ((*canonical_search_token)[0] == '"')
294 *canonical_search_token = canonical_search_token->substr(1);
295 while ((*canonical_search_token)[0] == '-')
296 *canonical_search_token = canonical_search_token->substr(1);
298 options->flag_name_substring_search = false;
299 options->flag_location_substring_search = false;
300 options->flag_description_substring_search = false;
301 options->return_all_matching_flags = false;
302 options->force_no_update = false;
304 // Look for all search options we can deduce now. Do this by walking
305 // backwards through the term, looking for up to three '?' and up to
306 // one '+' as suffixed characters. Consume them if found, and remove
307 // them from the canonical search token.
308 int found_question_marks = 0;
309 int found_plusses = 0;
311 if (found_question_marks < 3 &&
312 RemoveTrailingChar(canonical_search_token, '?')) {
313 ++found_question_marks;
316 if (found_plusses < 1 &&
317 RemoveTrailingChar(canonical_search_token, '+')) {
324 switch (found_question_marks) { // all fallthroughs
325 case 3: options->flag_description_substring_search = true;
326 case 2: options->flag_location_substring_search = true;
327 case 1: options->flag_name_substring_search = true;
330 options->return_all_matching_flags = (found_plusses > 0);
333 // Returns true if a char was removed
334 static bool RemoveTrailingChar(string *str, char c) {
335 if (str->empty()) return false;
336 if ((*str)[str->size() - 1] == c) {
337 *str = str->substr(0, str->size() - 1);
344 // 2) Find all matches (and helper methods)
345 static void FindMatchingFlags(
346 const vector<CommandLineFlagInfo> &all_flags,
347 const CompletionOptions &options,
348 const string &match_token,
349 set<const CommandLineFlagInfo *> *all_matches,
350 string *longest_common_prefix) {
351 all_matches->clear();
352 bool first_match = true;
353 for (vector<CommandLineFlagInfo>::const_iterator it = all_flags.begin();
354 it != all_flags.end();
356 if (DoesSingleFlagMatch(*it, options, match_token)) {
357 all_matches->insert(&*it);
360 *longest_common_prefix = it->name;
362 if (longest_common_prefix->empty() || it->name.empty()) {
363 longest_common_prefix->clear();
366 string::size_type pos = 0;
367 while (pos < longest_common_prefix->size() &&
368 pos < it->name.size() &&
369 (*longest_common_prefix)[pos] == it->name[pos])
371 longest_common_prefix->erase(pos);
377 // Given the set of all flags, the parsed match options, and the
378 // canonical search token, produce the set of all candidate matching
379 // flags for subsequent analysis or filtering.
380 static bool DoesSingleFlagMatch(
381 const CommandLineFlagInfo &flag,
382 const CompletionOptions &options,
383 const string &match_token) {
384 // Is there a prefix match?
385 string::size_type pos = flag.name.find(match_token);
386 if (pos == 0) return true;
388 // Is there a substring match if we want it?
389 if (options.flag_name_substring_search &&
393 // Is there a location match if we want it?
394 if (options.flag_location_substring_search &&
395 flag.filename.find(match_token) != string::npos)
398 // TODO(daven): All searches should probably be case-insensitive
399 // (especially this one...)
400 if (options.flag_description_substring_search &&
401 flag.description.find(match_token) != string::npos)
407 // 3) Categorize matches (and helper method)
409 // Given a set of matching flags, categorize them by
410 // likely relevence to this specific binary
411 static void CategorizeAllMatchingFlags(
412 const set<const CommandLineFlagInfo *> &all_matches,
413 const string &search_token,
414 const string &module, // empty if we couldn't find any
415 const string &package_dir, // empty if we couldn't find any
416 NotableFlags *notable_flags) {
417 notable_flags->perfect_match_flag.clear();
418 notable_flags->module_flags.clear();
419 notable_flags->package_flags.clear();
420 notable_flags->most_common_flags.clear();
421 notable_flags->subpackage_flags.clear();
423 for (set<const CommandLineFlagInfo *>::const_iterator it =
425 it != all_matches.end();
427 //VLOG(2) << "Examining match '" << (*it)->name << "'";
428 //VLOG(7) << " filename: '" << (*it)->filename << "'";
429 string::size_type pos = string::npos;
430 if (!package_dir.empty())
431 pos = (*it)->filename.find(package_dir);
432 string::size_type slash = string::npos;
433 if (pos != string::npos) // candidate for package or subpackage match
434 slash = (*it)->filename.find(
436 pos + package_dir.size() + 1);
438 if ((*it)->name == search_token) {
439 // Exact match on some flag's name
440 notable_flags->perfect_match_flag.insert(*it);
441 //VLOG(3) << "Result: perfect match";
442 } else if (!module.empty() && (*it)->filename == module) {
443 // Exact match on module filename
444 notable_flags->module_flags.insert(*it);
445 //VLOG(3) << "Result: module match";
446 } else if (!package_dir.empty() &&
447 pos != string::npos && slash == string::npos) {
448 // In the package, since there was no slash after the package portion
449 notable_flags->package_flags.insert(*it);
450 //VLOG(3) << "Result: package match";
452 // In the list of the XXX most commonly supplied flags overall
453 // TODO(daven): Compile this list.
454 //VLOG(3) << "Result: most-common match";
455 } else if (!package_dir.empty() &&
456 pos != string::npos && slash != string::npos) {
457 // In a subdirectory of the package
458 notable_flags->subpackage_flags.insert(*it);
459 //VLOG(3) << "Result: subpackage match";
462 //VLOG(3) << "Result: not special match";
466 static void TryFindModuleAndPackageDir(
467 const vector<CommandLineFlagInfo> all_flags,
469 string *package_dir) {
471 package_dir->clear();
473 vector<string> suffixes;
474 // TODO(daven): There's some inherant ambiguity here - multiple directories
475 // could share the same trailing folder and file structure (and even worse,
476 // same file names), causing us to be unsure as to which of the two is the
477 // actual package for this binary. In this case, we'll arbitrarily choose.
478 string progname(ProgramInvocationShortName());
479 suffixes.push_back("/" + progname + ".");
480 suffixes.push_back("/" + progname + "-main.");
481 suffixes.push_back("/" + progname + "_main.");
482 // These four are new but probably merited?
483 suffixes.push_back("/" + progname + "_test.");
484 suffixes.push_back("/" + progname + "-test.");
485 suffixes.push_back("/" + progname + "_unittest.");
486 suffixes.push_back("/" + progname + "-unittest.");
488 for (vector<CommandLineFlagInfo>::const_iterator it = all_flags.begin();
489 it != all_flags.end();
491 for (vector<string>::const_iterator suffix = suffixes.begin();
492 suffix != suffixes.end();
494 // TODO(daven): Make sure the match is near the end of the string
495 if (it->filename.find(*suffix) != string::npos) {
496 *module = it->filename;
497 string::size_type sep = it->filename.rfind(PATH_SEPARATOR);
498 *package_dir = it->filename.substr(0, (sep == string::npos) ? 0 : sep);
505 // Can't specialize template type on a locally defined type. Silly C++...
506 struct DisplayInfoGroup {
509 set<const CommandLineFlagInfo *> *group;
511 int SizeInLines() const {
512 int size_in_lines = static_cast<int>(group->size()) + 1;
513 if (!header.empty()) {
516 if (!footer.empty()) {
519 return size_in_lines;
523 // 4) Finalize and trim output flag set
524 static void FinalizeCompletionOutput(
525 const set<const CommandLineFlagInfo *> &matching_flags,
526 CompletionOptions *options,
527 NotableFlags *notable_flags,
528 vector<string> *completions) {
530 // We want to output lines in groups. Each group needs to be indented
531 // the same to keep its lines together. Unless otherwise required,
532 // only 99 lines should be output to prevent bash from harassing the
535 // First, figure out which output groups we'll actually use. For each
536 // nonempty group, there will be ~3 lines of header & footer, plus all
537 // output lines themselves.
538 int max_desired_lines = // "999999 flags should be enough for anyone. -dave"
539 (options->return_all_matching_flags ? 999999 : 98);
540 int lines_so_far = 0;
542 vector<DisplayInfoGroup> output_groups;
543 bool perfect_match_found = false;
544 if (lines_so_far < max_desired_lines &&
545 !notable_flags->perfect_match_flag.empty()) {
546 perfect_match_found = true;
547 DisplayInfoGroup group =
550 ¬able_flags->perfect_match_flag };
551 lines_so_far += group.SizeInLines();
552 output_groups.push_back(group);
554 if (lines_so_far < max_desired_lines &&
555 !notable_flags->module_flags.empty()) {
556 DisplayInfoGroup group = {
557 "-* Matching module flags *-",
558 "===========================",
559 ¬able_flags->module_flags };
560 lines_so_far += group.SizeInLines();
561 output_groups.push_back(group);
563 if (lines_so_far < max_desired_lines &&
564 !notable_flags->package_flags.empty()) {
565 DisplayInfoGroup group = {
566 "-* Matching package flags *-",
567 "============================",
568 ¬able_flags->package_flags };
569 lines_so_far += group.SizeInLines();
570 output_groups.push_back(group);
572 if (lines_so_far < max_desired_lines &&
573 !notable_flags->most_common_flags.empty()) {
574 DisplayInfoGroup group = {
575 "-* Commonly used flags *-",
576 "=========================",
577 ¬able_flags->most_common_flags };
578 lines_so_far += group.SizeInLines();
579 output_groups.push_back(group);
581 if (lines_so_far < max_desired_lines &&
582 !notable_flags->subpackage_flags.empty()) {
583 DisplayInfoGroup group = {
584 "-* Matching sub-package flags *-",
585 "================================",
586 ¬able_flags->subpackage_flags };
587 lines_so_far += group.SizeInLines();
588 output_groups.push_back(group);
591 set<const CommandLineFlagInfo *> obscure_flags; // flags not notable
592 if (lines_so_far < max_desired_lines) {
593 RetrieveUnusedFlags(matching_flags, *notable_flags, &obscure_flags);
594 if (!obscure_flags.empty()) {
595 DisplayInfoGroup group = {
599 lines_so_far += group.SizeInLines();
600 output_groups.push_back(group);
604 // Second, go through each of the chosen output groups and output
605 // as many of those flags as we can, while remaining below our limit
606 int remaining_lines = max_desired_lines;
607 size_t completions_output = 0;
608 int indent = static_cast<int>(output_groups.size()) - 1;
609 for (vector<DisplayInfoGroup>::const_iterator it =
610 output_groups.begin();
611 it != output_groups.end();
613 OutputSingleGroupWithLimit(
615 string(indent, ' '), // line indentation
616 it->header, // header
617 it->footer, // footer
618 perfect_match_found, // long format
619 &remaining_lines, // line limit - reduces this by number printed
620 &completions_output, // completions (not lines) added
621 completions); // produced completions
622 perfect_match_found = false;
625 if (completions_output != matching_flags.size()) {
626 options->force_no_update = false;
627 completions->push_back("~ (Remaining flags hidden) ~");
629 options->force_no_update = true;
633 static void RetrieveUnusedFlags(
634 const set<const CommandLineFlagInfo *> &matching_flags,
635 const NotableFlags ¬able_flags,
636 set<const CommandLineFlagInfo *> *unused_flags) {
637 // Remove from 'matching_flags' set all members of the sets of
638 // flags we've already printed (specifically, those in notable_flags)
639 for (set<const CommandLineFlagInfo *>::const_iterator it =
640 matching_flags.begin();
641 it != matching_flags.end();
643 if (notable_flags.perfect_match_flag.count(*it) ||
644 notable_flags.module_flags.count(*it) ||
645 notable_flags.package_flags.count(*it) ||
646 notable_flags.most_common_flags.count(*it) ||
647 notable_flags.subpackage_flags.count(*it))
649 unused_flags->insert(*it);
653 // 5) Output matches (and helpfer methods)
655 static void OutputSingleGroupWithLimit(
656 const set<const CommandLineFlagInfo *> &group,
657 const string &line_indentation,
658 const string &header,
659 const string &footer,
660 bool long_output_format,
661 int *remaining_line_limit,
662 size_t *completion_elements_output,
663 vector<string> *completions) {
664 if (group.empty()) return;
665 if (!header.empty()) {
666 if (*remaining_line_limit < 2) return;
667 *remaining_line_limit -= 2;
668 completions->push_back(line_indentation + header);
669 completions->push_back(line_indentation + string(header.size(), '-'));
671 for (set<const CommandLineFlagInfo *>::const_iterator it = group.begin();
672 it != group.end() && *remaining_line_limit > 0;
674 --*remaining_line_limit;
675 ++*completion_elements_output;
676 completions->push_back(
678 ? GetLongFlagLine(line_indentation, **it)
679 : GetShortFlagLine(line_indentation, **it)));
681 if (!footer.empty()) {
682 if (*remaining_line_limit < 1) return;
683 --*remaining_line_limit;
684 completions->push_back(line_indentation + footer);
688 static string GetShortFlagLine(
689 const string &line_indentation,
690 const CommandLineFlagInfo &info) {
692 line_indentation + "--" + info.name + " [" +
693 (info.type == "string" ?
694 ("'" + info.default_value + "'") :
698 FLAGS_tab_completion_columns - static_cast<int>(prefix.size());
702 (static_cast<int>(info.description.size()) > remainder ?
703 (info.description.substr(0, remainder - 3) + "...").c_str() :
704 info.description.c_str());
705 return prefix + suffix;
708 static string GetLongFlagLine(
709 const string &line_indentation,
710 const CommandLineFlagInfo &info) {
712 string output = DescribeOneFlag(info);
714 // Replace '-' with '--', and remove trailing newline before appending
715 // the module definition location.
716 string old_flagname = "-" + info.name;
718 output.find(old_flagname),
721 // Stick a newline and indentation in front of the type and default
722 // portions of DescribeOneFlag()s description
723 static const char kNewlineWithIndent[] = "\n ";
724 output.replace(output.find(" type:"), 1, string(kNewlineWithIndent));
725 output.replace(output.find(" default:"), 1, string(kNewlineWithIndent));
726 output = line_indentation + " Details for '--" + info.name + "':\n" +
727 output + " defined: " + info.filename;
729 // Eliminate any doubled newlines that crept in. Specifically, if
730 // DescribeOneFlag() decided to break the line just before "type"
731 // or "default", we don't want to introduce an extra blank line
732 static const string line_of_spaces(FLAGS_tab_completion_columns, ' ');
733 static const char kDoubledNewlines[] = "\n \n";
734 for (string::size_type newlines = output.find(kDoubledNewlines);
735 newlines != string::npos;
736 newlines = output.find(kDoubledNewlines))
737 // Replace each 'doubled newline' with a single newline
738 output.replace(newlines, sizeof(kDoubledNewlines) - 1, string("\n"));
740 for (string::size_type newline = output.find('\n');
741 newline != string::npos;
742 newline = output.find('\n')) {
743 int newline_pos = static_cast<int>(newline) % FLAGS_tab_completion_columns;
744 int missing_spaces = FLAGS_tab_completion_columns - newline_pos;
745 output.replace(newline, 1, line_of_spaces, 1, missing_spaces);
751 void HandleCommandLineCompletions(void) {
752 if (FLAGS_tab_completion_word.empty()) return;
753 PrintFlagCompletionInfo();
757 _END_GOOGLE_NAMESPACE_