Skip to content

Commit

Permalink
Merge branch 'remove-deprecate-message' of https://github.com/kubo39/…
Browse files Browse the repository at this point in the history
…docopt.d into kubo39-remove-deprecate-message
  • Loading branch information
rwtolbert committed Jan 1, 2017
2 parents 2ba6e61 + 6209a6e commit 86ee68d
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 26 deletions.
4 changes: 1 addition & 3 deletions dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@
"license": "MIT",
"sourcePaths": ["source"],
"importPaths": ["source"],
"targetType": "library",
"dependencies": {
}
"targetType": "library"
}
1 change: 1 addition & 0 deletions examples/arguments/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
arguments
1 change: 1 addition & 0 deletions examples/naval_fate/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
naval_fate
9 changes: 4 additions & 5 deletions source/docopt.d
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import std.conv;
import core.stdc.stdlib;
import std.json;

import argvalue;
import patterns;
import tokens;
private import argvalue;
private import patterns;
private import tokens;

class DocoptLanguageError : Exception {
this(string message, string file = __FILE__, size_t line = __LINE__) {
Expand Down Expand Up @@ -506,7 +506,7 @@ private string prettyArgValue(ArgValue[string] dict) {

public string prettyPrintArgs(ArgValue[string] args) {
JSONValue result = parseJSON(prettyArgValue(args));
return toJSON(&result, true);
return result.toPrettyString;
}

version(unittest)
Expand All @@ -517,7 +517,6 @@ version(unittest)
}

unittest {

// Commands
ArgValue[string] empty;
assert(docopt("Usage: prog", []) == empty);
Expand Down
26 changes: 13 additions & 13 deletions source/patterns.d
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ package struct PatternMatch {
}
}

package abstract class Pattern {
abstract class Pattern {
override bool opEquals(Object rhs) {
return (this.toString() == rhs.toString());
}
Expand Down Expand Up @@ -166,7 +166,7 @@ private Pattern transform(Pattern pattern) {
}


package class LeafPattern : Pattern {
class LeafPattern : Pattern {
string _name = null;
ArgValue _value = null;

Expand Down Expand Up @@ -274,7 +274,7 @@ package class LeafPattern : Pattern {

}

package class Option : LeafPattern {
class Option : LeafPattern {
string _shortArg;
string _longArg;
uint _argCount;
Expand Down Expand Up @@ -340,7 +340,7 @@ package class Option : LeafPattern {
}
}

package class BranchPattern : Pattern {
class BranchPattern : Pattern {
Pattern[] _children;

protected this() {
Expand Down Expand Up @@ -394,7 +394,7 @@ package class BranchPattern : Pattern {
}
}

protected Pattern[] removeChild(Pattern[] arr, Pattern child) {
Pattern[] removeChild(Pattern[] arr, Pattern child) {
Pattern[] result;
bool found = false;
foreach(pat; arr) {
Expand All @@ -408,7 +408,7 @@ protected Pattern[] removeChild(Pattern[] arr, Pattern child) {
return result;
}

package class Argument : LeafPattern {
class Argument : LeafPattern {
this(string name, ArgValue value) {
super(name, value);
}
Expand Down Expand Up @@ -450,7 +450,7 @@ package class Argument : LeafPattern {
}
}

package class Command : Argument {
class Command : Argument {
this(string name, ArgValue value) {
super(name, value);
}
Expand All @@ -476,7 +476,7 @@ package class Command : Argument {
}
}

package class Required : BranchPattern {
class Required : BranchPattern {
this(Pattern[] children) {
super(children);
}
Expand Down Expand Up @@ -506,7 +506,7 @@ package class Required : BranchPattern {
}
}

package class Optional : BranchPattern {
class Optional : BranchPattern {
this(Pattern[] children) {
super(children);
}
Expand All @@ -528,7 +528,7 @@ package class Optional : BranchPattern {
}
}

package class OptionsShortcut : Optional {
class OptionsShortcut : Optional {
this() {
super([]);
}
Expand All @@ -548,7 +548,7 @@ package class OptionsShortcut : Optional {
}
}

package class OneOrMore : BranchPattern {
class OneOrMore : BranchPattern {
this(Pattern[] children) {
super(children);
}
Expand Down Expand Up @@ -591,7 +591,7 @@ package class OneOrMore : BranchPattern {
}
}

package class Either : BranchPattern {
class Either : BranchPattern {
this(Pattern[] children) {
super(children);
}
Expand Down Expand Up @@ -633,7 +633,7 @@ package class Either : BranchPattern {
}
}

protected Option parseOption(string optionDescription) {
Option parseOption(string optionDescription) {
string shortArg = null;
string longArg = null;
uint argCount = 0;
Expand Down
2 changes: 1 addition & 1 deletion source/tokens.d
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import std.string;
import std.regex;
import std.array;

package class Tokens {
class Tokens {
string[] _list;
bool _isParsingArgv;
this(string[] source, bool parsingArgv = true) {
Expand Down
8 changes: 4 additions & 4 deletions source/unittests.d
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ string sortedJSON(string input) {
}

bool compareJSON(JSONValue expect, JSONValue result) {
string strE = sortedJSON(toJSON(&expect, true));
string strR = sortedJSON(toJSON(&result, true));
string strE = sortedJSON(expect.toPrettyString);
string strR = sortedJSON(result.toPrettyString);
if (strE == strR) {
return true;
}
Expand Down Expand Up @@ -74,7 +74,7 @@ class DocoptTestItem {
//writeln(result);
} catch (DocoptArgumentError e) {
result = "\"user-error\"";
return (result == toJSON(&_expect));
return (result == _expect.toPrettyString);
} catch (Exception e) {
writeln(e);
return false;
Expand All @@ -84,7 +84,7 @@ class DocoptTestItem {
if (compareJSON(_expect, _result)) {
return true;
} else {
writeln(format("expect: %s\nresult: %s",
writeln(format("expect: %s\nresult: %s",
_expect, _result));
return false;
}
Expand Down

0 comments on commit 86ee68d

Please sign in to comment.