-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path{ModuleCsID}.cs
68 lines (56 loc) · 2.07 KB
/
{ModuleCsID}.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using OrbitalShell.Component.CommandLine.CommandModel;
using OrbitalShell.Component.Shell.Module;
using OrbitalShell.Component.Shell.Hook;
using OrbitalShell.Component.Shell;
using OrbitalShell.Component.Shell.Variable;
using OrbitalShell.Component.CommandLine.Processor;
using System;
using System.IO;
using System.Linq;
using OrbitalShell.Component.Console;
using System.Collections.Generic;
namespace OrbitalShell.Module.{ModuleCsID}
{
/// <summary>
/// module {ModuleTitle}
/// </summary>
[Commands("{ModuleDescription}")]
[CommandsNamespace(CommandNamespace.tools, ToolNamespace)]
[Hooks]
public class {ModuleCsID}Commands : ICommandsDeclaringType
{
#region attributes
public const string ToolNamespace = "{ModuleToolNamespace}";
public const string ToolVarSettingsName = "{ModuleToolVarSettingsName}";
public const string VarIsEnabled = "isEnabled";
string _namespace => Variables.Nsp(ShellEnvironmentNamespace.com + "", ToolNamespace, ToolVarSettingsName);
#endregion
#region init
/// <summary>
/// init module hook
/// </summary>
[Hook(Hooks.ModuleInit)]
public void Init(CommandEvaluationContext context)
{
// init settings
context.ShellEnv.AddNew(_namespace, VarIsEnabled, true, false);
// ... add your own inits here ...
}
#endregion
#region Command
/// <summary>
/// enable or disable module
/// </summary>
[Command("enable/disable module {ModuleTitle}")]
public CommandVoidResult {ModuleCsID}(
CommandEvaluationContext context,
[Option("e", "enable", "if true enable the module, otherwise disable it", true, true)] bool isEnabled = true
)
{
context.Variables.SetValue(Variables.Nsp(VariableNamespace.env + "", _namespace), VarIsEnabled, isEnabled);
return CommandVoidResult.Instance;
}
// add your own hooks ...
#endregion
}
}