Skip to content

Commit c40ebbd

Browse files
Removed gratuitous changes and fixed whitespace
1 parent 2739729 commit c40ebbd

File tree

4 files changed

+263
-263
lines changed

4 files changed

+263
-263
lines changed

src/System.CommandLine.Subsystems/Directives/DiagramSubsystem.cs

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -76,78 +76,78 @@ private static void Diagram(
7676
break;
7777
*/
7878

79-
// TODO: This logic is deeply tied to internal types/properties. These aren't things we probably want to expose like SymbolNode. See #2349 for alternatives
80-
/*
81-
case ArgumentResult argumentResult:
82-
{
83-
var includeArgumentName =
84-
argumentResult.Argument.FirstParent!.Symbol is CliCommand { HasArguments: true, Arguments.Count: > 1 };
85-
86-
if (includeArgumentName)
79+
// TODO: This logic is deeply tied to internal types/properties. These aren't things we probably want to expose like SymbolNode. See #2349 for alternatives
80+
/*
81+
case ArgumentResult argumentResult:
8782
{
88-
builder.Append("[ ");
89-
builder.Append(argumentResult.Argument.Name);
90-
builder.Append(' ');
91-
}
83+
var includeArgumentName =
84+
argumentResult.Argument.FirstParent!.Symbol is CliCommand { HasArguments: true, Arguments.Count: > 1 };
9285
93-
if (argumentResult.Argument.Arity.MaximumNumberOfValues > 0)
94-
{
95-
ArgumentConversionResult conversionResult = argumentResult.GetArgumentConversionResult();
96-
switch (conversionResult.Result)
86+
if (includeArgumentName)
9787
{
98-
case ArgumentConversionResultType.NoArgument:
99-
break;
100-
case ArgumentConversionResultType.Successful:
101-
switch (conversionResult.Value)
102-
{
103-
case string s:
104-
builder.Append($"<{s}>");
105-
break;
106-
107-
case IEnumerable items:
108-
builder.Append('<');
109-
builder.Append(
110-
string.Join("> <",
111-
items.Cast<object>().ToArray()));
112-
builder.Append('>');
113-
break;
114-
115-
default:
116-
builder.Append('<');
117-
builder.Append(conversionResult.Value);
118-
builder.Append('>');
119-
break;
120-
}
121-
122-
break;
123-
124-
default: // failures
125-
builder.Append('<');
126-
builder.Append(string.Join("> <", symbolResult.Tokens.Select(t => t.Value)));
127-
builder.Append('>');
128-
129-
break;
88+
builder.Append("[ ");
89+
builder.Append(argumentResult.Argument.Name);
90+
builder.Append(' ');
13091
}
131-
}
13292
133-
if (includeArgumentName)
134-
{
135-
builder.Append(" ]");
136-
}
93+
if (argumentResult.Argument.Arity.MaximumNumberOfValues > 0)
94+
{
95+
ArgumentConversionResult conversionResult = argumentResult.GetArgumentConversionResult();
96+
switch (conversionResult.Result)
97+
{
98+
case ArgumentConversionResultType.NoArgument:
99+
break;
100+
case ArgumentConversionResultType.Successful:
101+
switch (conversionResult.Value)
102+
{
103+
case string s:
104+
builder.Append($"<{s}>");
105+
break;
106+
107+
case IEnumerable items:
108+
builder.Append('<');
109+
builder.Append(
110+
string.Join("> <",
111+
items.Cast<object>().ToArray()));
112+
builder.Append('>');
113+
break;
114+
115+
default:
116+
builder.Append('<');
117+
builder.Append(conversionResult.Value);
118+
builder.Append('>');
119+
break;
120+
}
121+
122+
break;
123+
124+
default: // failures
125+
builder.Append('<');
126+
builder.Append(string.Join("> <", symbolResult.Tokens.Select(t => t.Value)));
127+
builder.Append('>');
128+
129+
break;
130+
}
131+
}
137132
138-
break;
139-
}
133+
if (includeArgumentName)
134+
{
135+
builder.Append(" ]");
136+
}
140137
141-
default:
142-
{
143-
OptionResult? optionResult = symbolResult as OptionResult;
138+
break;
139+
}
144140
145-
if (optionResult is { Implicit: true })
141+
default:
146142
{
147-
builder.Append('*');
148-
}
143+
OptionResult? optionResult = symbolResult as OptionResult;
144+
145+
if (optionResult is { Implicit: true })
146+
{
147+
builder.Append('*');
148+
}
149149
150-
builder.Append("[ ");
150+
builder.Append("[ ");
151151
152152
if (optionResult is not null)
153153
{

src/System.CommandLine.Tests/ParserTests.cs

Lines changed: 97 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -854,124 +854,124 @@ public void Absolute_Windows_style_paths_are_lexed_correctly()
854854
}
855855

856856
/* These tests should be split and those using an explicit default value moved to subsystem, and those using the type default should remain in core (?). This might not be meaningful if the type conversion is correct. What value other than the type default could be used.
857-
[Fact]
858-
public void Commands_can_have_default_argument_values()
859-
{
860-
var argument = new CliArgument<string>("the-arg")
861-
{
862-
DefaultValueFactory = (_) => "default"
863-
};
857+
[Fact]
858+
public void Commands_can_have_default_argument_values()
859+
{
860+
var argument = new CliArgument<string>("the-arg")
861+
{
862+
DefaultValueFactory = (_) => "default"
863+
};
864864
865-
var command = new CliCommand("command")
866-
{
867-
argument
868-
};
865+
var command = new CliCommand("command")
866+
{
867+
argument
868+
};
869869
870-
ParseResult result = CliParser.Parse(command, "command");
870+
ParseResult result = CliParser.Parse(command, "command");
871871
872-
GetValue(result, argument)
873-
.Should()
874-
.Be("default");
875-
}
872+
GetValue(result, argument)
873+
.Should()
874+
.Be("default");
875+
}
876876
877-
[Fact]
878-
public void When_an_option_with_a_default_value_is_not_matched_then_the_option_can_still_be_accessed_as_though_it_had_been_applied()
879-
{
880-
var command = new CliCommand("command");
881-
var option = new CliOption<string>("-o", "--option")
882-
{
883-
DefaultValueFactory = (_) => "the-default"
884-
};
885-
command.Options.Add(option);
877+
[Fact]
878+
public void When_an_option_with_a_default_value_is_not_matched_then_the_option_can_still_be_accessed_as_though_it_had_been_applied()
879+
{
880+
var command = new CliCommand("command");
881+
var option = new CliOption<string>("-o", "--option")
882+
{
883+
DefaultValueFactory = (_) => "the-default"
884+
};
885+
command.Options.Add(option);
886886
887-
ParseResult result = CliParser.Parse(command, "command");
887+
ParseResult result = CliParser.Parse(command, "command");
888888
889-
result.GetResult(option).Should().NotBeNull();
890-
GetValue(result, option).Should().Be("the-default");
891-
}
889+
result.GetResult(option).Should().NotBeNull();
890+
GetValue(result, option).Should().Be("the-default");
891+
}
892892
893-
[Fact]
894-
public void When_an_option_with_a_default_value_is_not_matched_then_the_option_result_is_implicit()
895-
{
896-
var option = new CliOption<string>("-o", "--option")
897-
{
898-
DefaultValueFactory = (_) => "the-default"
899-
};
893+
[Fact]
894+
public void When_an_option_with_a_default_value_is_not_matched_then_the_option_result_is_implicit()
895+
{
896+
var option = new CliOption<string>("-o", "--option")
897+
{
898+
DefaultValueFactory = (_) => "the-default"
899+
};
900900
901-
var command = new CliCommand("command")
902-
{
903-
option
904-
};
901+
var command = new CliCommand("command")
902+
{
903+
option
904+
};
905905
906-
var result = CliParser.Parse(command, "command");
906+
var result = CliParser.Parse(command, "command");
907907
908-
result.GetResult(option)
909-
.Implicit
910-
.Should()
911-
.BeTrue();
912-
}
908+
result.GetResult(option)
909+
.Implicit
910+
.Should()
911+
.BeTrue();
912+
}
913913
914-
[Fact]
915-
public void When_an_option_with_a_default_value_is_not_matched_then_there_are_no_tokens()
916-
{
917-
var option = new CliOption<string>("-o")
918-
{
919-
DefaultValueFactory = (_) => "the-default"
920-
};
914+
[Fact]
915+
public void When_an_option_with_a_default_value_is_not_matched_then_there_are_no_tokens()
916+
{
917+
var option = new CliOption<string>("-o")
918+
{
919+
DefaultValueFactory = (_) => "the-default"
920+
};
921921
922-
var command = new CliCommand("command")
923-
{
924-
option
925-
};
922+
var command = new CliCommand("command")
923+
{
924+
option
925+
};
926926
927-
var result = CliParser.Parse(command, "command");
927+
var result = CliParser.Parse(command, "command");
928928
929-
result.GetResult(option)
930-
.IdentifierToken
931-
.Should()
932-
.BeEquivalentTo(default(CliToken));
933-
}
929+
result.GetResult(option)
930+
.IdentifierToken
931+
.Should()
932+
.BeEquivalentTo(default(CliToken));
933+
}
934934
935-
[Fact]
936-
public void When_an_argument_with_a_default_value_is_not_matched_then_there_are_no_tokens()
937-
{
938-
var argument = new CliArgument<string>("o")
939-
{
940-
DefaultValueFactory = (_) => "the-default"
941-
};
935+
[Fact]
936+
public void When_an_argument_with_a_default_value_is_not_matched_then_there_are_no_tokens()
937+
{
938+
var argument = new CliArgument<string>("o")
939+
{
940+
DefaultValueFactory = (_) => "the-default"
941+
};
942942
943-
var command = new CliCommand("command")
944-
{
945-
argument
946-
};
947-
var result = CliParser.Parse(command, "command");
943+
var command = new CliCommand("command")
944+
{
945+
argument
946+
};
947+
var result = CliParser.Parse(command, "command");
948948
949-
result.GetResult(argument)
950-
.Tokens
951-
.Should()
952-
.BeEmpty();
953-
}
949+
result.GetResult(argument)
950+
.Tokens
951+
.Should()
952+
.BeEmpty();
953+
}
954954
955-
[Fact]
956-
public void Command_default_argument_value_does_not_override_parsed_value()
957-
{
958-
var argument = new CliArgument<DirectoryInfo>("the-arg")
959-
{
960-
DefaultValueFactory = (_) => new DirectoryInfo(Directory.GetCurrentDirectory())
961-
};
955+
[Fact]
956+
public void Command_default_argument_value_does_not_override_parsed_value()
957+
{
958+
var argument = new CliArgument<DirectoryInfo>("the-arg")
959+
{
960+
DefaultValueFactory = (_) => new DirectoryInfo(Directory.GetCurrentDirectory())
961+
};
962962
963-
var command = new CliCommand("inner")
964-
{
965-
argument
966-
};
963+
var command = new CliCommand("inner")
964+
{
965+
argument
966+
};
967967
968-
var result = CliParser.Parse(command, "the-directory");
968+
var result = CliParser.Parse(command, "the-directory");
969969
970-
GetValue(result, argument)
971-
.Name
972-
.Should()
973-
.Be("the-directory");
974-
}
970+
GetValue(result, argument)
971+
.Name
972+
.Should()
973+
.Be("the-directory");
974+
}
975975
*/
976976

977977
[Fact]

0 commit comments

Comments
 (0)