[feat] Abyssctl Basic functions
This commit is contained in:
		| @@ -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; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										20
									
								
								abyssctl/App/Modules/InitOptions.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								abyssctl/App/Modules/InitOptions.cs
									
									
									
									
									
										Normal 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; | ||||
|     } | ||||
| } | ||||
							
								
								
									
										26
									
								
								abyssctl/App/Modules/UserAddOptions.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								abyssctl/App/Modules/UserAddOptions.cs
									
									
									
									
									
										Normal 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; | ||||
|     } | ||||
| } | ||||
| @@ -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 | ||||
| { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 acite
					acite