Skip to content

Commit

Permalink
Use environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
maisiesadler committed May 4, 2021
1 parent a271732 commit bd08303
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
14 changes: 7 additions & 7 deletions runindocker.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/bin/bash

result=$(dotnet /DepTree.Console.dll \
-a $ASSEMBLY_LOCATION \
--config $APPLICATION_CONFIG_LOCATION \
-t $ROOT_TYPE \
-s $SKIP_TYPE \
-n $ASSEMBLY_CONFIG_LOCATION \
-i $INTERFACE_RESOLVER)
result=$(ASSEMBLY_LOCATION=$ASSEMBLY_LOCATION \
APPLICATION_CONFIG_LOCATION=$APPLICATION_CONFIG_LOCATION \
ROOT_TYPE=$ROOT_TYPE \
SKIP_TYPE=$SKIP_TYPE \
ASSEMBLY_CONFIG_LOCATION=$ASSEMBLY_CONFIG_LOCATION \
INTERFACE_RESOLVER=$INTERFACE_RESOLVER \
dotnet /DepTree.Console.dll)

r=$?
if [ $r -ne 0 ]; then
Expand Down
18 changes: 16 additions & 2 deletions src/DepTree.Console/Configuration/ApplicationConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,31 @@ private void Validate()

private void ReadEnvironmentVariables()
{
AssemblyLocation = Environment.GetEnvironmentVariable("ASSEMBLY_LOCATION");
_assemblyConfigLocation = Environment.GetEnvironmentVariable("ASSEMBLY_CONFIG_LOCATION");
_configLocation = Environment.GetEnvironmentVariable("CONFIG_LOCATION");
_configLocation = Environment.GetEnvironmentVariable("APPLICATION_CONFIG_LOCATION");
InterfaceResolver = Environment.GetEnvironmentVariable("INTERFACE_RESOLVER");

var rootType = Environment.GetEnvironmentVariable("ROOT_TYPE");
if (!string.IsNullOrWhiteSpace(rootType))
{
var types = rootType.Split(",", StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
Generate.AddRange(types);
}

var skipType = Environment.GetEnvironmentVariable("SKIP_TYPE");
if (!string.IsNullOrWhiteSpace(skipType))
{
var skip = skipType.Split(",", StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
foreach (var s in skip) Skip.Add(s);
}
}

private void TryReadArgs(string[] args)
{
var parser = Parser.Default.ParseArguments<CommandLineInputs>(() => new(), args);
parser.WithParsed(inputs =>
{
System.Console.WriteLine("CLI inputs: " + JsonSerializer.Serialize(inputs));
if (!string.IsNullOrWhiteSpace(inputs.AssemblyLocation))
AssemblyLocation = inputs.AssemblyLocation;

Expand Down

0 comments on commit bd08303

Please sign in to comment.