mirror of
https://github.com/dlang/phobos.git
synced 2025-04-30 07:00:37 +03:00
getopt public undocumented symbols and style
some of the symbols where clearly only used from within getopt but still where public. additionally some style violation fixes
This commit is contained in:
parent
fb7d68882e
commit
014ff8e155
1 changed files with 10 additions and 6 deletions
16
std/getopt.d
16
std/getopt.d
|
@ -425,7 +425,8 @@ to another program). Invoking the example above with $(D "--foo -- --bar")
|
||||||
parses foo but leaves "--bar" in $(D args). The double-dash itself is
|
parses foo but leaves "--bar" in $(D args). The double-dash itself is
|
||||||
removed from the argument array.
|
removed from the argument array.
|
||||||
*/
|
*/
|
||||||
GetoptResult getopt(T...)(ref string[] args, T opts) {
|
GetoptResult getopt(T...)(ref string[] args, T opts)
|
||||||
|
{
|
||||||
import std.exception : enforce;
|
import std.exception : enforce;
|
||||||
enforce(args.length,
|
enforce(args.length,
|
||||||
"Invalid arguments string passed: program name missing");
|
"Invalid arguments string passed: program name missing");
|
||||||
|
@ -500,7 +501,7 @@ struct Option {
|
||||||
/// an error.
|
/// an error.
|
||||||
}
|
}
|
||||||
|
|
||||||
pure Option splitAndGet(string opt) @trusted nothrow
|
private pure Option splitAndGet(string opt) @trusted nothrow
|
||||||
{
|
{
|
||||||
import std.array : split;
|
import std.array : split;
|
||||||
auto sp = split(opt, "|");
|
auto sp = split(opt, "|");
|
||||||
|
@ -614,7 +615,7 @@ private void getoptImpl(T...)(ref string[] args, ref configuration cfg,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool handleOption(R)(string option, R receiver, ref string[] args,
|
private bool handleOption(R)(string option, R receiver, ref string[] args,
|
||||||
ref configuration cfg, bool incremental)
|
ref configuration cfg, bool incremental)
|
||||||
{
|
{
|
||||||
import std.algorithm : map, splitter;
|
import std.algorithm : map, splitter;
|
||||||
|
@ -622,7 +623,8 @@ bool handleOption(R)(string option, R receiver, ref string[] args,
|
||||||
import std.conv : text, to;
|
import std.conv : text, to;
|
||||||
// Scan arguments looking for a match for this option
|
// Scan arguments looking for a match for this option
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
for (size_t i = 1; i < args.length; ) {
|
for (size_t i = 1; i < args.length; )
|
||||||
|
{
|
||||||
auto a = args[i];
|
auto a = args[i];
|
||||||
if (endOfOptions.length && a == endOfOptions) break;
|
if (endOfOptions.length && a == endOfOptions) break;
|
||||||
if (cfg.stopOnFirstNonOption && (!a.length || a[0] != optionChar))
|
if (cfg.stopOnFirstNonOption && (!a.length || a[0] != optionChar))
|
||||||
|
@ -685,7 +687,8 @@ bool handleOption(R)(string option, R receiver, ref string[] args,
|
||||||
enum isCallbackWithLessThanTwoParameters =
|
enum isCallbackWithLessThanTwoParameters =
|
||||||
(is(typeof(receiver) == delegate) || is(typeof(*receiver) == function)) &&
|
(is(typeof(receiver) == delegate) || is(typeof(*receiver) == function)) &&
|
||||||
!is(typeof(receiver("", "")));
|
!is(typeof(receiver("", "")));
|
||||||
if (!isCallbackWithLessThanTwoParameters && !(val.length) && !incremental) {
|
if (!isCallbackWithLessThanTwoParameters && !(val.length) && !incremental)
|
||||||
|
{
|
||||||
// Eat the next argument too. Check to make sure there's one
|
// Eat the next argument too. Check to make sure there's one
|
||||||
// to be eaten first, though.
|
// to be eaten first, though.
|
||||||
enforce(i < args.length,
|
enforce(i < args.length,
|
||||||
|
@ -1351,7 +1354,8 @@ message is present it will be printed after the long version of the
|
||||||
$(D Option).
|
$(D Option).
|
||||||
|
|
||||||
------------
|
------------
|
||||||
foreach(it; opt) {
|
foreach(it; opt)
|
||||||
|
{
|
||||||
writefln("%*s %*s %s", lengthOfLongestShortOption, it.optShort,
|
writefln("%*s %*s %s", lengthOfLongestShortOption, it.optShort,
|
||||||
lengthOfLongestLongOption, it.optLong, it.help);
|
lengthOfLongestLongOption, it.optLong, it.help);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue