[feat] Abyssctl Basic functions

This commit is contained in:
acite
2025-10-05 16:48:54 +08:00
parent 50eae5e275
commit a0273e3334
22 changed files with 428 additions and 238 deletions

View File

@@ -1,22 +1,30 @@
using abyssctl.App.Attributes;
using abyssctl.App.Interfaces;
using abyssctl.Model;
using CommandLine;
namespace abyssctl.App.Modules;
[Module(100)]
[Verb("hello", HelpText = "Say hello to abyss server")]
public class HelloOptions: IOptions
{
[Option('r', "raw", Default = false, HelpText = "Show raw response.")]
public bool Raw { get; set; }
public async Task<int> Run()
{
var r = await App.CtlWriteRead(new Ctl
var r = await App.CtlWriteRead<HelloOptions>([]);
if (Raw)
{
Head = 100,
Params = []
});
Console.WriteLine($"Response Code: {r.Head}");
Console.WriteLine($"Params: {string.Join(",", r.Params)}");
Console.WriteLine($"Response Code: {r.Head}");
Console.WriteLine($"Params: {string.Join(",", r.Params)}");
}
else
{
Console.WriteLine($"Server: {string.Join(",", r.Params)}");
}
return 0;
}
}

View File

@@ -0,0 +1,20 @@
using abyssctl.App.Attributes;
using abyssctl.App.Interfaces;
using CommandLine;
namespace abyssctl.App.Modules;
[Module(103)]
[Verb("init", HelpText = "Initialize abyss server")]
public class InitOptions: IOptions
{
public async Task<int> Run()
{
var r = await App.CtlWriteRead<InitOptions>([]);
Console.WriteLine($"Response Code: {r.Head}");
Console.WriteLine($"Params: {string.Join(",", r.Params)}");
return 0;
}
}

View File

@@ -0,0 +1,26 @@
using abyssctl.App.Attributes;
using abyssctl.App.Interfaces;
using CommandLine;
namespace abyssctl.App.Modules;
[Module(104)]
[Verb("useradd", HelpText = "Add user")]
public class UserAddOptions: IOptions
{
[Option('u', "username", Required = true, HelpText = "Username for new user.")]
public string Username { get; set; } = "";
[Option('p', "privilege", Required = true, HelpText = "User privilege.")]
public int Privilege { get; set; }
public async Task<int> Run()
{
var r = await App.CtlWriteRead<UserAddOptions>([Username, Privilege.ToString()]);
Console.WriteLine($"Response Code: {r.Head}");
Console.WriteLine($"Params: {string.Join(",", r.Params)}");
return 0;
}
}

View File

@@ -1,8 +1,10 @@
using abyssctl.App.Attributes;
using abyssctl.App.Interfaces;
using CommandLine;
namespace abyssctl.App.Modules;
[Module(101)]
[Verb("ver", HelpText = "Get server version")]
public class VersionOptions: IOptions
{