[feat] Abyssctl Basic functions 2
This commit is contained in:
28
abyssctl/App/Modules/ChmodOptions.cs
Normal file
28
abyssctl/App/Modules/ChmodOptions.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using abyssctl.App.Attributes;
|
||||
using abyssctl.App.Interfaces;
|
||||
using CommandLine;
|
||||
|
||||
namespace abyssctl.App.Modules;
|
||||
|
||||
[Module(106)]
|
||||
[Verb("chmod", HelpText = "Change resources permissions")]
|
||||
public class ChmodOptions: IOptions
|
||||
{
|
||||
[Value(0, MetaName = "path", Required = true, HelpText = "Relative path to resources.")]
|
||||
public string Path { get; set; } = "";
|
||||
|
||||
[Value(1, MetaName = "permission", Required = true, HelpText = "Permission mask.")]
|
||||
public string Permission { get; set; } = "";
|
||||
|
||||
[Option('r', "recursive", Default = false, HelpText = "Recursive change resources.")]
|
||||
public bool Recursive { get; set; }
|
||||
public async Task<int> Run()
|
||||
{
|
||||
var r = await App.CtlWriteRead<ChmodOptions>([Path, Permission, Recursive.ToString()]);
|
||||
|
||||
Console.WriteLine($"Response Code: {r.Head}");
|
||||
Console.WriteLine($"Params: {string.Join(",", r.Params)}");
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
29
abyssctl/App/Modules/IncludeOptions.cs
Normal file
29
abyssctl/App/Modules/IncludeOptions.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using abyssctl.App.Attributes;
|
||||
using abyssctl.App.Interfaces;
|
||||
using CommandLine;
|
||||
|
||||
namespace abyssctl.App.Modules;
|
||||
|
||||
[Module(105)]
|
||||
[Verb("include", HelpText = "include resources to system")]
|
||||
public class IncludeOptions: IOptions
|
||||
{
|
||||
[Value(0, MetaName = "path", Required = true, HelpText = "Relative path to resources.")]
|
||||
public string Path { get; set; } = "";
|
||||
|
||||
[Value(1, MetaName = "owner", Required = true, HelpText = "Owner id.")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Option('r', "recursive", Default = false, HelpText = "Recursive include resources.")]
|
||||
public bool Recursive { get; set; }
|
||||
|
||||
public async Task<int> Run()
|
||||
{
|
||||
var r = await App.CtlWriteRead<IncludeOptions>([Path, Id.ToString(), Recursive.ToString()]);
|
||||
|
||||
Console.WriteLine($"Response Code: {r.Head}");
|
||||
Console.WriteLine($"Params: {string.Join(",", r.Params)}");
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
30
abyssctl/App/Modules/ListOptions.cs
Normal file
30
abyssctl/App/Modules/ListOptions.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using abyssctl.App.Attributes;
|
||||
using abyssctl.App.Interfaces;
|
||||
using CommandLine;
|
||||
|
||||
namespace abyssctl.App.Modules;
|
||||
|
||||
[Module(107)]
|
||||
[Verb("list", HelpText = "List items")]
|
||||
public class ListOptions: IOptions
|
||||
{
|
||||
[Value(0, MetaName = "path", Required = true, HelpText = "Relative path to resources.")]
|
||||
public string Path { get; set; } = "";
|
||||
|
||||
public async Task<int> Run()
|
||||
{
|
||||
var r = await App.CtlWriteRead<ListOptions>([Path]);
|
||||
|
||||
if (r.Head != 200)
|
||||
{
|
||||
Console.WriteLine($"Response Code: {r.Head}");
|
||||
Console.WriteLine($"Params: {string.Join(",", r.Params)}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine(r.Params[0]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,12 @@ namespace abyssctl.App.Modules;
|
||||
[Verb("useradd", HelpText = "Add user")]
|
||||
public class UserAddOptions: IOptions
|
||||
{
|
||||
[Option('u', "username", Required = true, HelpText = "Username for new user.")]
|
||||
[Value(0, MetaName = "username", Required = true, HelpText = "Username for new user.")]
|
||||
public string Username { get; set; } = "";
|
||||
|
||||
[Option('p', "privilege", Required = true, HelpText = "User privilege.")]
|
||||
[Value(1, MetaName = "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()]);
|
||||
|
||||
Reference in New Issue
Block a user