Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 52fecbb436 | |||
| 363c078321 |
@@ -25,6 +25,13 @@ jobs:
|
|||||||
TAG="${GITHUB_REF_NAME#v}"
|
TAG="${GITHUB_REF_NAME#v}"
|
||||||
echo "PACKAGE_VERSION=$TAG" >> $GITHUB_OUTPUT
|
echo "PACKAGE_VERSION=$TAG" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Replace ProjectReference with PackageReference
|
||||||
|
run: |
|
||||||
|
sed -i "s#<ProjectReference Include=\"..\/ArgumentsToolkit.Core\/ArgumentsToolkit.Core.csproj\" />#<PackageReference Include=\"ArgumentsToolkit.Core\" Version=\"${{ steps.version.outputs.PACKAGE_VERSION }}\" />#" ArgumentsToolkit.Help/ArgumentsToolkit.Help.csproj
|
||||||
|
sed -i "s#<ProjectReference Include=\"..\/ArgumentsToolkit.Core\/ArgumentsToolkit.Core.csproj\" />#<PackageReference Include=\"ArgumentsToolkit.Core\" Version=\"${{ steps.version.outputs.PACKAGE_VERSION }}\" />#" ArgumentsToolkit.Validation/ArgumentsToolkit.Validation.csproj
|
||||||
|
sed -i "s#<ProjectReference Include=\"..\/ArgumentsToolkit.Core\/ArgumentsToolkit.Core.csproj\" />#<PackageReference Include=\"ArgumentsToolkit.Core\" Version=\"${{ steps.version.outputs.PACKAGE_VERSION }}\" />#" ArgumentsToolkit/ArgumentsToolkit.csproj
|
||||||
|
sed -i "s#<ProjectReference Include=\"..\/ArgumentsToolkit.Help\/ArgumentsToolkit.Help.csproj\" />#<PackageReference Include=\"ArgumentsToolkit.Help\" Version=\"${{ steps.version.outputs.PACKAGE_VERSION }}\" />#" ArgumentsToolkit/ArgumentsToolkit.csproj
|
||||||
|
sed -i "s#<ProjectReference Include=\"..\/ArgumentsToolkit.Validation\/ArgumentsToolkit.Validation.csproj\" />#<PackageReference Include=\"ArgumentsToolkit.Validation\" Version=\"${{ steps.version.outputs.PACKAGE_VERSION }}\" />#" ArgumentsToolkit/ArgumentsToolkit.csproj
|
||||||
|
|
||||||
- name: Build and Pack projects
|
- name: Build and Pack projects
|
||||||
run: |
|
run: |
|
||||||
@@ -39,10 +46,10 @@ jobs:
|
|||||||
done
|
done
|
||||||
env:
|
env:
|
||||||
PROJECTS: |
|
PROJECTS: |
|
||||||
ArgumentsToolkit
|
|
||||||
ArgumentsToolkit.Core
|
ArgumentsToolkit.Core
|
||||||
ArgumentsToolkit.Help
|
ArgumentsToolkit.Help
|
||||||
ArgumentsToolkit.Validation
|
ArgumentsToolkit.Validation
|
||||||
|
ArgumentsToolkit
|
||||||
|
|
||||||
|
|
||||||
- name: Upload package artifacts
|
- name: Upload package artifacts
|
||||||
|
|||||||
@@ -136,10 +136,16 @@ public static class ArgumentsParser
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string ToArguments<T>(T options)
|
/// <summary>
|
||||||
|
/// Формирование строки аргументов
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="options"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string ToArguments<T>(T options, bool useShortName = false)
|
||||||
{
|
{
|
||||||
var props = typeof(T).GetProperties();
|
var props = typeof(T).GetProperties();
|
||||||
var parts = new List<string>();
|
var parts = new List<KeyValuePair<string, string>>();
|
||||||
|
|
||||||
foreach (var prop in props)
|
foreach (var prop in props)
|
||||||
{
|
{
|
||||||
@@ -151,17 +157,22 @@ public static class ArgumentsParser
|
|||||||
|
|
||||||
string prefix = "--" + opt.Name;
|
string prefix = "--" + opt.Name;
|
||||||
|
|
||||||
|
if (useShortName && !string.IsNullOrWhiteSpace(opt.ShortName))
|
||||||
|
{
|
||||||
|
prefix = "-" + opt.ShortName;
|
||||||
|
}
|
||||||
|
|
||||||
if (prop.PropertyType == typeof(bool))
|
if (prop.PropertyType == typeof(bool))
|
||||||
{
|
{
|
||||||
if ((bool)value)
|
if ((bool)value)
|
||||||
parts.Add(prefix);
|
parts.Add(new(prefix, ""));
|
||||||
}
|
}
|
||||||
else if (prop.PropertyType.IsGenericType &&
|
else if (prop.PropertyType.IsGenericType &&
|
||||||
prop.PropertyType.GetGenericTypeDefinition() == typeof(List<>))
|
prop.PropertyType.GetGenericTypeDefinition() == typeof(List<>))
|
||||||
{
|
{
|
||||||
var list = (System.Collections.IList)value;
|
var list = (System.Collections.IList)value;
|
||||||
if (list.Count > 0)
|
if (list.Count > 0)
|
||||||
parts.Add($"{prefix} {string.Join(",", list.Cast<object>())}");
|
parts.Add(new(prefix, string.Join(",", list.Cast<object>())));
|
||||||
}
|
}
|
||||||
else if (prop.PropertyType.IsGenericType &&
|
else if (prop.PropertyType.IsGenericType &&
|
||||||
prop.PropertyType.GetGenericTypeDefinition() == typeof(Dictionary<,>))
|
prop.PropertyType.GetGenericTypeDefinition() == typeof(Dictionary<,>))
|
||||||
@@ -171,15 +182,15 @@ public static class ArgumentsParser
|
|||||||
foreach (var k in dict.Keys)
|
foreach (var k in dict.Keys)
|
||||||
items.Add($"{k}={dict[k]}");
|
items.Add($"{k}={dict[k]}");
|
||||||
if (items.Count > 0)
|
if (items.Count > 0)
|
||||||
parts.Add($"{prefix} {string.Join(",", items)}");
|
parts.Add(new(prefix, string.Join(",", items)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
parts.Add($"{prefix} {value}");
|
parts.Add(new(prefix, $"{value}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return string.Join(" ", parts);
|
return string.Join(" ", parts.Select(kvp => kvp.Key + " \"" + kvp.Value + "\""));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool TryParse(Type targetType, string input, IOptionConverter? converterAttr, out object? value)
|
private static bool TryParse(Type targetType, string input, IOptionConverter? converterAttr, out object? value)
|
||||||
|
|||||||
@@ -40,10 +40,14 @@ internal class Program
|
|||||||
Console.WriteLine($"Environment: {result.Value.Environment}");
|
Console.WriteLine($"Environment: {result.Value.Environment}");
|
||||||
Console.WriteLine($"DryRun: {result.Value.DryRun}");
|
Console.WriteLine($"DryRun: {result.Value.DryRun}");
|
||||||
Console.WriteLine($"Mode: {result.Value.Mode}");
|
Console.WriteLine($"Mode: {result.Value.Mode}");
|
||||||
|
Console.WriteLine($"Path: {result.Value.Path}");
|
||||||
Console.WriteLine($"Config.Author: {result.Value.Config.Author}");
|
Console.WriteLine($"Config.Author: {result.Value.Config.Author}");
|
||||||
Console.WriteLine($"Config.Timeout: {result.Value.Config.Timeout}");
|
Console.WriteLine($"Config.Timeout: {result.Value.Config.Timeout}");
|
||||||
Console.ResetColor();
|
Console.ResetColor();
|
||||||
|
|
||||||
|
Console.WriteLine("Строка аргументов:");
|
||||||
|
Console.WriteLine(ArgumentsParser.ToArguments(result.Value!, true));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -63,6 +67,9 @@ public class DeployOptions
|
|||||||
[AllowedValues("dev", "staging", "prod")]
|
[AllowedValues("dev", "staging", "prod")]
|
||||||
public string Environment { get; set; } = "dev";
|
public string Environment { get; set; } = "dev";
|
||||||
|
|
||||||
|
[Option("path", null, "Среда деплоя")]
|
||||||
|
public string? Path { get; set; }
|
||||||
|
|
||||||
[Option("dry-run", "d", "Пробный запуск без изменений")]
|
[Option("dry-run", "d", "Пробный запуск без изменений")]
|
||||||
public bool DryRun { get; set; }
|
public bool DryRun { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"profiles": {
|
"profiles": {
|
||||||
"Demo": {
|
"Demo": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"commandLineArgs": "--server myhost --port 8080 --env staging --mode Incremental --config \"{\\\"Author\\\":\\\"FrigaT\\\",\\\"Timeout\\\":60}"
|
"commandLineArgs": "--server \"myhost\" --port 8080 --path \"C:\\Job\\Projects\\FrigaT\\ReleaseUpdater\\Updater.Test\\bin\\Debug\\net8.0\" --env staging --mode Incremental --config \"{\\\"Author\\\":\\\"FrigaT\\\",\\\"Timeout\\\":60} "
|
||||||
},
|
},
|
||||||
"Demo (Error)": {
|
"Demo (Error)": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
|
|||||||
Reference in New Issue
Block a user