mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-05-06 03:32:57 +00:00
dotnet-cli
This commit is contained in:
parent
512b07ce8a
commit
381251fc8e
19
Esiur.CLI/Esiur.CLI.csproj
Normal file
19
Esiur.CLI/Esiur.CLI.csproj
Normal file
@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<PackAsTool>true</PackAsTool>
|
||||
<ToolCommandName>esiur</ToolCommandName>
|
||||
<PackageOutputPath>./nupkg</PackageOutputPath>
|
||||
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Esiur\Esiur.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
76
Esiur.CLI/Program.cs
Normal file
76
Esiur.CLI/Program.cs
Normal file
@ -0,0 +1,76 @@
|
||||
|
||||
using Esiur.Data;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
|
||||
if (args.Length > 0)
|
||||
{
|
||||
if (args[0].ToLower() == "get-template" && args.Length >= 2)
|
||||
{
|
||||
try
|
||||
{
|
||||
var url = args[1];
|
||||
|
||||
var parameters = GetParams(args, 2);
|
||||
|
||||
|
||||
var username = args.ElementAtOrDefault(3);
|
||||
var password = args.ElementAtOrDefault(4);
|
||||
var asyncSetters = Convert.ToBoolean(args.ElementAtOrDefault(5));
|
||||
|
||||
var path = Esiur.Proxy.TemplateGenerator.GetTemplate(url,
|
||||
parameters["-d"] ?? parameters["--dir"],
|
||||
parameters["-u"] ?? parameters["--username"],
|
||||
parameters["-p"] ?? parameters["--password"],
|
||||
parameters["-d"] ?? parameters["--dir"]
|
||||
parameters.Contains ["--a"] ?? parameters["--dir"]);
|
||||
|
||||
Console.WriteLine($"Generated successfully: {path}");
|
||||
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PrintHelp();
|
||||
}
|
||||
|
||||
static StringKeyList GetParams(string[] args, int offset)
|
||||
{
|
||||
var rt = new StringKeyList();
|
||||
for(var i = offset; i< args.Length; i+=2)
|
||||
{
|
||||
var v = args.Length >= (i + 1) ? args[i+1] : null;
|
||||
rt.Add(args[i], v);
|
||||
}
|
||||
|
||||
return rt;
|
||||
}
|
||||
|
||||
static void PrintHelp()
|
||||
{
|
||||
var version = FileVersionInfo.GetVersionInfo(typeof(Esiur.Core.AsyncReply).Assembly.Location).FileVersion;
|
||||
|
||||
|
||||
Console.WriteLine("Usage: <command> [arguments]");
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Available commands:");
|
||||
Console.WriteLine("\tget-template\t\tGet a template from an IIP link.");
|
||||
Console.WriteLine("\tversion\t\tPrint Esiur version.");
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Global options:");
|
||||
Console.WriteLine("\t-u, --username\tAuthentication username.");
|
||||
Console.WriteLine("\t-p, --password\tAuthentication password.");
|
||||
Console.WriteLine("\t-d, --dir\tName of the directory to generate model inside.");
|
||||
|
||||
}
|
@ -22,7 +22,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.7" />
|
||||
<PackageReference Include="System.Collections" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -12,7 +12,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test", "Test\Test.csproj",
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Esiur.Security.Cryptography", "Esiur.Security.Cryptography\Esiur.Security.Cryptography.csproj", "{C0C55C1A-7C48-41EB-9A65-27BC99D82F6D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Esiur.Examples.StandaloneWebServerDemo", "Esiur.Examples.StandaloneWebServerDemo\Esiur.Examples.StandaloneWebServerDemo.csproj", "{A00BBD34-601D-4803-94AE-B807DC75D53A}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Esiur.Examples.StandaloneWebServerDemo", "Esiur.Examples.StandaloneWebServerDemo\Esiur.Examples.StandaloneWebServerDemo.csproj", "{A00BBD34-601D-4803-94AE-B807DC75D53A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Esiur.CLI", "Esiur.CLI\Esiur.CLI.csproj", "{5C193127-20D1-4709-90C4-DF714D7E6700}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -44,6 +46,10 @@ Global
|
||||
{A00BBD34-601D-4803-94AE-B807DC75D53A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A00BBD34-601D-4803-94AE-B807DC75D53A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A00BBD34-601D-4803-94AE-B807DC75D53A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5C193127-20D1-4709-90C4-DF714D7E6700}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5C193127-20D1-4709-90C4-DF714D7E6700}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5C193127-20D1-4709-90C4-DF714D7E6700}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5C193127-20D1-4709-90C4-DF714D7E6700}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -37,27 +37,24 @@ namespace Esiur.Data;
|
||||
public class StringKeyList : IEnumerable<KeyValuePair<string, string>>
|
||||
{
|
||||
|
||||
//private List<string> m_keys = new List<string>();
|
||||
//private List<string> m_values = new List<string>();
|
||||
|
||||
private List<KeyValuePair<string, string>> m_Variables = new List<KeyValuePair<string, string>>();
|
||||
|
||||
private bool allowMultiple;
|
||||
|
||||
public delegate void Modified(string Key, string NewValue);
|
||||
public delegate void Modified(string key, string newValue);
|
||||
public event Modified OnModified;
|
||||
|
||||
public StringKeyList(bool AllowMultipleValues = false)
|
||||
public StringKeyList(bool allowMultipleValues = false)
|
||||
{
|
||||
allowMultiple = AllowMultipleValues;
|
||||
allowMultiple = allowMultipleValues;
|
||||
}
|
||||
|
||||
public void Add(string Key, string Value)
|
||||
public void Add(string key, string value)
|
||||
{
|
||||
if (OnModified != null)
|
||||
OnModified(Key, Value);
|
||||
OnModified(key, value);
|
||||
|
||||
var key = Key.ToLower();
|
||||
key = key.ToLower();
|
||||
|
||||
if (!allowMultiple)
|
||||
{
|
||||
@ -71,14 +68,14 @@ public class StringKeyList : IEnumerable<KeyValuePair<string, string>>
|
||||
}
|
||||
}
|
||||
|
||||
m_Variables.Add(new KeyValuePair<string, string>(Key, Value));
|
||||
m_Variables.Add(new KeyValuePair<string, string>(key, value));
|
||||
}
|
||||
|
||||
public string this[string Key]
|
||||
public string this[string key]
|
||||
{
|
||||
get
|
||||
{
|
||||
var key = Key.ToLower();
|
||||
key = key.ToLower();
|
||||
foreach (var kv in m_Variables)
|
||||
if (kv.Key.ToLower() == key)
|
||||
return kv.Value;
|
||||
@ -87,7 +84,7 @@ public class StringKeyList : IEnumerable<KeyValuePair<string, string>>
|
||||
}
|
||||
set
|
||||
{
|
||||
var key = Key.ToLower();
|
||||
key = key.ToLower();
|
||||
|
||||
var toRemove = m_Variables.Where(x => x.Key.ToLower() == key).ToArray();
|
||||
|
||||
@ -95,16 +92,15 @@ public class StringKeyList : IEnumerable<KeyValuePair<string, string>>
|
||||
m_Variables.Remove(item);
|
||||
|
||||
|
||||
m_Variables.Add(new KeyValuePair<string, string>(Key, value));
|
||||
m_Variables.Add(new KeyValuePair<string, string>(key, value));
|
||||
|
||||
OnModified?.Invoke(Key, value);
|
||||
OnModified?.Invoke(key, value);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator<KeyValuePair<string, string>> IEnumerable<KeyValuePair<string, string>>.GetEnumerator()
|
||||
{
|
||||
//return m_keys.GetEnumerator();
|
||||
return m_Variables.GetEnumerator();
|
||||
}
|
||||
|
||||
@ -122,26 +118,6 @@ public class StringKeyList : IEnumerable<KeyValuePair<string, string>>
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
public string[] Keys
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_keys.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//public Dictionary<string, string>.ValueCollection Values
|
||||
public string[] Values
|
||||
{
|
||||
get
|
||||
{
|
||||
//return m_Variables.Values;
|
||||
return m_values.ToArray();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public List<string> GetValues(string Key)
|
||||
{
|
||||
@ -156,21 +132,21 @@ public class StringKeyList : IEnumerable<KeyValuePair<string, string>>
|
||||
return values;
|
||||
}
|
||||
|
||||
public void RemoveAll(string Key)
|
||||
public void RemoveAll(string key)
|
||||
{
|
||||
while (Remove(Key)) { }
|
||||
while (Remove(key)) { }
|
||||
}
|
||||
|
||||
public bool Remove(string Key)
|
||||
public bool Remove(string key)
|
||||
{
|
||||
var key = Key.ToLower();
|
||||
key = key.ToLower();
|
||||
|
||||
foreach (var kv in m_Variables)
|
||||
{
|
||||
if (kv.Key.ToLower() == key)
|
||||
{
|
||||
if (OnModified != null)
|
||||
OnModified(Key, null);
|
||||
OnModified(key, null);
|
||||
m_Variables.Remove(kv);
|
||||
return true;
|
||||
}
|
||||
@ -184,36 +160,24 @@ public class StringKeyList : IEnumerable<KeyValuePair<string, string>>
|
||||
get { return m_Variables.Count; }
|
||||
}
|
||||
|
||||
public bool ContainsKey(string Key)
|
||||
public bool ContainsKey(string key)
|
||||
{
|
||||
var key = Key.ToLower();
|
||||
key = key.ToLower();
|
||||
foreach (var kv in m_Variables)
|
||||
if (kv.Key.ToLower() == key)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
public bool ContainsKey(string Key)
|
||||
{
|
||||
//return m_Variables.ContainsKey(Key);
|
||||
return m_keys.Contains(Key.ToLower());
|
||||
}
|
||||
*/
|
||||
|
||||
public bool ContainsValue(string Value)
|
||||
public bool ContainsValue(string value)
|
||||
{
|
||||
var value = Value.ToLower();
|
||||
value = value.ToLower();
|
||||
foreach (var kv in m_Variables)
|
||||
if (kv.Value.ToLower() == value)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//internal KeyList()
|
||||
//{
|
||||
// m_Session = Session;
|
||||
// m_Server = Server;
|
||||
//}
|
||||
|
||||
}
|
@ -63,7 +63,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.9.2" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.10.0" />
|
||||
<PackageReference Include="System.Collections" Version="4.3.0" />
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||
<PackageReference Include="System.Diagnostics.StackTrace" Version="4.3.0" />
|
||||
@ -74,10 +74,10 @@
|
||||
<PackageReference Include="System.Net.Security" Version="4.3.2" />
|
||||
<PackageReference Include="System.Reflection.Emit" Version="4.7.0" />
|
||||
<PackageReference Include="System.Reflection.Emit.Lightweight" Version="4.7.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="8.0.3" GeneratePathProperty="true" />
|
||||
<PackageReference Include="System.Text.Json" Version="8.0.4" GeneratePathProperty="true" />
|
||||
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
|
||||
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.9.2" PrivateAssets="all" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" PrivateAssets="all" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" PrivateAssets="all" />
|
||||
|
||||
</ItemGroup>
|
||||
|
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017-2023 Esiur Foundation, Ahmed Kh. Zamil.
|
||||
Copyright (c) 2017-2024 Esiur Foundation, Ahmed Kh. Zamil.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
Loading…
x
Reference in New Issue
Block a user