Skip to content

Commit

Permalink
支持可以带参数自启
Browse files Browse the repository at this point in the history
  • Loading branch information
SpringHgui committed Mar 12, 2021
1 parent 523fc0b commit 65e82f6
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 21 deletions.
1 change: 1 addition & 0 deletions src/SuiDao.Client/HttpHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public static Task<string> PostAsJson(string uri, string strContent)
httpclient.BaseAddress = new Uri(uri);
var content = new StringContent(strContent, Encoding.UTF8, "application/json");

// api1.suidao.io
var response = httpclient.PostAsync(uri, content).Result;
if (response.StatusCode == HttpStatusCode.OK)
{
Expand Down
42 changes: 41 additions & 1 deletion src/SuiDao.Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class Program

/// <summary>
/// suidao.io 客户端
/// 参数规范定义 [指令 参数]
/// 指令
/// login [AccessKey]
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
Expand All @@ -35,6 +38,37 @@ static void Main(string[] args)
var logger = LogManager.GetCurrentClassLogger();
logger.Info("===== SuiDao Client Start =====");

if (args.Length == 0)
{
defaultLogic(logger);
return;
}

switch (args[0])
{
case "login":
loginByKey(logger, args);
break;
default:
Console.WriteLine($"{args[0]} 指令不存在");
break;
}
}

private static void loginByKey(Logger logger, string[] args)
{
if (args.Length < 2)
{
Console.WriteLine($"参数不全");
return;
}

var key = args[1];
LogByKey(key, logger, false);
}

public static void defaultLogic(ILogger logger)
{
var keyFile = Path.Combine(AppContext.BaseDirectory, KeyLogName);
if (!File.Exists(keyFile))
{
Expand Down Expand Up @@ -130,9 +164,15 @@ private static void HandleNum(List<string> keys, ILogger logger)

static IServiceProvider servicesProvider;

/// <summary>
/// 登录
/// </summary>
/// <param name="key"></param>
/// <param name="logger"></param>
/// <param name="log">是否记录登录记录</param>
private static void LogByKey(string key, ILogger logger, bool log)
{
Console.WriteLine("登录中...");
Console.WriteLine($"AccessKey={key} \n登录中...");

try
{
Expand Down
14 changes: 0 additions & 14 deletions src/SuiDao.Client/Properties/PublishProfiles/FolderProfile.pubxml

This file was deleted.

This file was deleted.

4 changes: 4 additions & 0 deletions src/SuiDao.Client/SuiDao.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<SignAssembly>false</SignAssembly>
<AssemblyOriginatorKeyFile>FastTunnel.pfx</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<AnalysisLevel>latest</AnalysisLevel>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 65e82f6

Please sign in to comment.