-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Command line parser prerequisites (#853)
* Expected-ize read_lines. * Introduce IReadLines as a smaller interface for things that just want to read lines. * Extract HelpTableFormatter and consistently use -s in source file names. * Rename IReadLines to ILineReader, as requested by Victor. * Name the numbers in HelpTableFormatter::format as requested by Victor. * Fix NPM authenticate.
- Loading branch information
1 parent
36ed4a8
commit 17bb1b8
Showing
56 changed files
with
264 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#include <vcpkg/base/system_headers.h> | ||
#include <vcpkg/base/system-headers.h> | ||
|
||
#include <catch2/catch.hpp> | ||
|
||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#include <vcpkg/base/fwd/cmd-parser.h> | ||
|
||
#include <vcpkg/base/stringview.h> | ||
|
||
#include <string> | ||
|
||
namespace vcpkg | ||
{ | ||
struct HelpTableFormatter | ||
{ | ||
// Adds a table entry with a key `col1` and value `col2` | ||
void format(StringView col1, StringView col2); | ||
// Adds an example block; typically just the text with no indenting | ||
void example(StringView example_text); | ||
// Adds a header typically placed at the top of several table entries | ||
void header(StringView name); | ||
// Adds a blank line | ||
void blank(); | ||
// Adds a line of text | ||
void text(StringView text, int indent = 0); | ||
|
||
std::string m_str; | ||
}; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
namespace vcpkg | ||
{ | ||
struct HelpTableFormatter; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include <catch2/catch.hpp> | ||
|
||
#include <vcpkg/base/cmd-parser.h> | ||
|
||
using namespace vcpkg; | ||
|
||
TEST_CASE ("Smoke test help table formatter", "[cmd_parser]") | ||
{ | ||
HelpTableFormatter uut; | ||
|
||
uut.header("This is a header"); | ||
uut.format("short-arg", "short help text"); | ||
uut.format("a-really-long-arg-that-does-not-fit-in-the-first-column-and-keeps-going", "shorty"); | ||
uut.format("short-arg", | ||
"some really long help text that does not fit on the same line because we have a 100 character line " | ||
"limit and oh god it keeps going and going"); | ||
uut.format("a-really-long-arg-combined-with-some-really-long-help-text", | ||
"another instance of that really long help text goes here to demonstrate that the worst case combo can " | ||
"be accommodated"); | ||
|
||
uut.blank(); | ||
uut.example("some example command"); | ||
uut.text("this is some text"); | ||
|
||
const char* const expected = R"(This is a header: | ||
short-arg short help text | ||
a-really-long-arg-that-does-not-fit-in-the-first-column-and-keeps-going | ||
shorty | ||
short-arg some really long help text that does not fit on the same line | ||
because we have a 100 character line limit and oh god it keeps | ||
going and going | ||
a-really-long-arg-combined-with-some-really-long-help-text | ||
another instance of that really long help text goes here to | ||
demonstrate that the worst case combo can be accommodated | ||
some example command | ||
this is some text)"; | ||
|
||
CHECK(uut.m_str == expected); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#include <vcpkg/base/system_headers.h> | ||
#include <vcpkg/base/system-headers.h> | ||
|
||
#include <catch2/catch.hpp> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#include <vcpkg/base/system_headers.h> | ||
#include <vcpkg/base/system-headers.h> | ||
|
||
#include <catch2/catch.hpp> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.