-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for environment args and volumes in run command. (#5)
- Loading branch information
1 parent
f7629ca
commit 356e7db
Showing
2 changed files
with
68 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace LclDckr.Commands.Run | ||
{ | ||
public class RunArguments | ||
{ | ||
public bool Interactive { get; set; } | ||
|
||
public string Name { get; set; } | ||
|
||
public string HostName { get; set; } | ||
|
||
public IDictionary<string, string> EnvironmentArgs = new Dictionary<string, string>(); | ||
|
||
public IList<string> Volumes = new List<string>(); | ||
|
||
public string ToArgString() | ||
{ | ||
var args = new StringBuilder("-d"); | ||
|
||
if (Interactive) | ||
{ | ||
args.Append("i"); | ||
} | ||
|
||
if (Name != null) | ||
{ | ||
args.Append($" --name {Name}"); | ||
} | ||
|
||
if (HostName != null) | ||
{ | ||
args.Append($" --hostname {HostName}"); | ||
} | ||
|
||
foreach (var environmentArg in EnvironmentArgs) | ||
{ | ||
args.Append($" -e {environmentArg.Key}={environmentArg.Value}"); | ||
} | ||
|
||
foreach (var volume in Volumes) | ||
{ | ||
args.Append($" -v {volume}"); | ||
} | ||
|
||
return args.ToString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters