Skip to content

Commit 95549b1

Browse files
Cleanup of redundant class (#1963)
## Why make this change? - Cleanup CliBoolean class as it is not adding any value and creating confusion with CliBool.cs ## How was this tested? - Existing tests
1 parent aa577bf commit 95549b1

File tree

5 files changed

+10
-23
lines changed

5 files changed

+10
-23
lines changed

src/Cli.Tests/TestHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ public static InitOptions CreateBasicInitOptionsForMsSqlWithConfig(string? confi
10821082
hostMode: HostMode.Development,
10831083
corsOrigin: new List<string>(),
10841084
authenticationProvider: EasyAuthType.StaticWebApps.ToString(),
1085-
restRequestBodyStrict: CliBoolean.True,
1085+
restRequestBodyStrict: CliBool.True,
10861086
config: config);
10871087
}
10881088
}

src/Cli/Commands/InitOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public InitOptions(
3636
bool graphqlDisabled = false,
3737
CliBool restEnabled = CliBool.None,
3838
CliBool graphqlEnabled = CliBool.None,
39-
CliBoolean restRequestBodyStrict = CliBoolean.None,
39+
CliBool restRequestBodyStrict = CliBool.None,
4040
string? config = null)
4141
: base(config)
4242
{
@@ -118,7 +118,7 @@ public InitOptions(
118118
// Since the rest.request-body-strict option does not have a default value, it is required to specify a value for this option if it is
119119
// included in the init command.
120120
[Option("rest.request-body-strict", Required = false, HelpText = "(Default: true) Allow extraneous fields in the request body for REST.")]
121-
public CliBoolean RestRequestBodyStrict { get; }
121+
public CliBool RestRequestBodyStrict { get; }
122122

123123
public void Handler(ILogger logger, FileSystemRuntimeConfigLoader loader, IFileSystem fileSystem)
124124
{

src/Cli/ConfigGenerator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public static bool TryCreateRuntimeConfig(InitOptions options, FileSystemRuntime
142142
_logger.LogWarning("Configuration option --rest.path is not honored for cosmosdb_nosql since CosmosDB does not support REST.");
143143
}
144144

145-
if (options.RestRequestBodyStrict is not CliBoolean.None)
145+
if (options.RestRequestBodyStrict is not CliBool.None)
146146
{
147147
_logger.LogWarning("Configuration option --rest.request-body-strict is not honored for cosmosdb_nosql since CosmosDB does not support REST.");
148148
}
@@ -232,7 +232,7 @@ public static bool TryCreateRuntimeConfig(InitOptions options, FileSystemRuntime
232232
Schema: dabSchemaLink,
233233
DataSource: dataSource,
234234
Runtime: new(
235-
Rest: new(restEnabled, restPath ?? RestRuntimeOptions.DEFAULT_PATH, options.RestRequestBodyStrict is CliBoolean.False ? false : true),
235+
Rest: new(restEnabled, restPath ?? RestRuntimeOptions.DEFAULT_PATH, options.RestRequestBodyStrict is CliBool.False ? false : true),
236236
GraphQL: new(graphQLEnabled, graphQLPath),
237237
Host: new(
238238
Cors: new(options.CorsOrigin?.ToArray() ?? Array.Empty<string>()),

src/Config/ObjectModel/CliBool.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33

44
namespace Azure.DataApiBuilder.Config.ObjectModel;
55

6+
/// <summary>
7+
/// Class to represent boolean values in CLI. This is required over primitive boolean types because of the limitation of the CommandLineParser library
8+
/// where if a boolean option is included in the CLI command, it is set as true.
9+
/// Doesn't matter what value we specify for the option as that value is ignored.
10+
/// </summary>
611
public enum CliBool
712
{
813
// The enum value None is required to determine whether a value was provided for a CLI option. In case the option is not included in the init command,

src/Config/ObjectModel/CliBoolean.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)