Skip to content

Commit 7e12074

Browse files
committed
Version 1.0.1.1
1 parent a466a52 commit 7e12074

File tree

45 files changed

+259
-54
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+259
-54
lines changed

Templates/PowerCommands.zip

1.77 KB
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using $safeprojectname$.Enums;
2+
3+
namespace $safeprojectname$.DomainObjects;
4+
5+
public class ToolbarConfiguration
6+
{
7+
public HideToollbarOption HideToollbarOption { get; set; } = HideToollbarOption.Never;
8+
public List<ToolbarItemConfiguration> ToolbarItems { get; set; } = new();
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace $safeprojectname$.DomainObjects;
2+
3+
public class ToolbarItemConfiguration
4+
{
5+
public string Label { get; set; } = string.Empty;
6+
public ConsoleColor Color { get; set; } = ConsoleColor.Cyan;
7+
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace $safeprojectname$.Enums;
2+
3+
public enum HideToollbarOption
4+
{
5+
Never,
6+
OnTextChange,
7+
OnCommandHighlighted
8+
}

Templates/src/Core/PainKiller.PowerCommands.Configuration/MyTemplate.vstemplate

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@
2626
<ProjectItem ReplaceParameters="true" TargetFileName="ConfigurationGlobals.cs">ConfigurationGlobals.cs</ProjectItem>
2727
<ProjectItem ReplaceParameters="true" TargetFileName="EncryptionConfiguration.cs">EncryptionConfiguration.cs</ProjectItem>
2828
<ProjectItem ReplaceParameters="true" TargetFileName="SecurityConfiguration.cs">SecurityConfiguration.cs</ProjectItem>
29+
<ProjectItem ReplaceParameters="true" TargetFileName="ToolbarConfiguration.cs">ToolbarConfiguration.cs</ProjectItem>
30+
<ProjectItem ReplaceParameters="true" TargetFileName="ToolbarItemConfiguration.cs">ToolbarItemConfiguration.cs</ProjectItem>
2931
<ProjectItem ReplaceParameters="true" TargetFileName="YamlContainer.cs">YamlContainer.cs</ProjectItem>
3032
</Folder>
33+
<Folder Name="Enums" TargetFolderName="Enums">
34+
<ProjectItem ReplaceParameters="true" TargetFileName="HideToollbarOption.cs">HideToollbarOption.cs</ProjectItem>
35+
</Folder>
3136
<Folder Name="Extensions" TargetFolderName="Extensions">
3237
<ProjectItem ReplaceParameters="true" TargetFileName="ConfigurationExtension.cs">ConfigurationExtension.cs</ProjectItem>
3338
</Folder>

Templates/src/Core/PainKiller.PowerCommands.Configuration/PainKiller.PowerCommands.Configuration.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<LangVersion>10.0</LangVersion>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
8-
<Version>1.0.1.0</Version>
8+
<Version>1.0.1.1</Version>
99
</PropertyGroup>
1010

1111
<ItemGroup>
@@ -14,6 +14,7 @@
1414

1515
<ItemGroup>
1616
<Folder Include="Extensions\" />
17+
<Folder Include="Enums\" />
1718
</ItemGroup>
1819

1920
</Project>

Templates/src/Core/PainKiller.PowerCommands.Core/BASECLASSES/CommandBase.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public virtual void RunCompleted()
8989
public void WriteHeadLine(string output) => _console.WriteHeaderLine(GetType().Name, output);
9090
public void WriteSuccess(string output) => _console.WriteSuccess(GetType().Name, output);
9191
public void WriteSuccessLine(string output) => _console.WriteSuccessLine(GetType().Name, output);
92+
public void WriteUrl(string output) => _console.WriteUrl(GetType().Name, output);
9293
public void WriteFailure(string output) => _console.Write(GetType().Name, output, ConsoleColor.DarkRed);
9394
public void WriteFailureLine(string output) => _console.WriteLine(GetType().Name, output, ConsoleColor.DarkRed);
9495
public void WriteWarning(string output) => _console.WriteWarning(GetType().Name, output);

Templates/src/Core/PainKiller.PowerCommands.Core/BASECLASSES/CommandWithToolbarBase.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
1-
using System.Timers;
2-
using PainKiller.PowerCommands.ReadLine;
1+
using PainKiller.PowerCommands.ReadLine;
32
using PainKiller.PowerCommands.ReadLine.Events;
3+
using System.Timers;
44

55
namespace $safeprojectname$.BaseClasses
66
{
77
public abstract class CommandWithToolbarBase<TConfig> : CommandBase<TConfig> where TConfig : new()
88
{
9-
private static string _latestHighightedCommand = string.Empty;
9+
protected string LatestHighlightedCommand = string.Empty;
1010
private readonly System.Timers.Timer _overflowTimer;
11+
private readonly bool _autoShowToolbar;
1112
private readonly ConsoleColor[]? _colors;
1213
protected List<string> Labels = new();
1314
protected PowerCommandsToolbarAttribute? ToolbarAttribute;
1415
protected CommandWithToolbarBase(string identifier, TConfig configuration, bool autoShowToolbar = true, ConsoleColor[]? colors = null) : base(identifier, configuration)
1516
{
17+
_autoShowToolbar = autoShowToolbar;
1618
_colors = colors;
17-
if (autoShowToolbar) ReadLineService.CommandHighlighted += ReadLineService_CommandHighlighted;
19+
ReadLineService.CommandHighlighted += ReadLineService_CommandHighlighted;
1820
ToolbarAttribute = this.GetToolbarAttribute();
1921
var overflowMilliseconds = ToolbarAttribute?.Timer ?? 500;
2022
_overflowTimer = new System.Timers.Timer(Math.Clamp(overflowMilliseconds, 500, 5000));
2123
ReadLineService.CmdLineTextChanged += ReadLineService_CmdLineTextChanged;
2224
}
2325
protected virtual void ReadLineService_CmdLineTextChanged(object? sender, CmdLineTextChangedArgs e)
2426
{
25-
if (!e.CmdText.StartsWith(Identifier) && _latestHighightedCommand == Identifier) ClearToolbar();
27+
if (!e.CmdText.StartsWith(Identifier) && LatestHighlightedCommand == Identifier) ClearToolbar();
2628
}
2729
public override RunResult Run()
2830
{
@@ -31,11 +33,14 @@ public override RunResult Run()
3133
}
3234
protected void ReadLineService_CommandHighlighted(object? sender, CommandHighlightedArgs e)
3335
{
34-
_latestHighightedCommand = e.CommandName;
36+
LatestHighlightedCommand = e.CommandName;
3537
if (e.CommandName != Identifier) return;
36-
_overflowTimer.Elapsed += InitializeToolbar;
37-
_overflowTimer.AutoReset = true;
38-
_overflowTimer.Enabled = true;
38+
if (_autoShowToolbar)
39+
{
40+
_overflowTimer.Elapsed += InitializeToolbar;
41+
_overflowTimer.AutoReset = true;
42+
_overflowTimer.Enabled = true;
43+
}
3944
}
4045
private void InitializeToolbar(object? sender, ElapsedEventArgs e)
4146
{

Templates/src/Core/PainKiller.PowerCommands.Core/COMMANDS/CdCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public override RunResult Run()
6666
path = string.Join(Path.DirectorySeparatorChar, paths);
6767
}
6868
if (path.Contains("$ROAMING$")) path = path.Replace("$ROAMING$", ConfigurationGlobals.ApplicationDataFolder);
69-
if (Directory.Exists(path)) WorkingDirectory = path;
69+
if (Directory.Exists(path)) WorkingDirectory = $"{Path.GetFullPath(path)}";
7070
else WriteFailureLine($"[{path}] does not exist");
7171
ShowDirectories();
7272
return Ok();

Templates/src/Core/PainKiller.PowerCommands.Core/COMMANDS/ExitCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
namespace $safeprojectname$.Commands;
22

3+
[PowerCommandsToolbar("[Exit? ->]|y(es)")]
34
[PowerCommandDesign( description: "Exit command exits the program",
45
arguments: "<answer>(any answer starting with y will close the application)",
56
suggestions: "y",
67
disableProxyOutput: true,
78
example: "exit|exit y|exit Yes")]
8-
public class ExitCommand : CommandBase<CommandsConfiguration>
9+
public class ExitCommand : CommandWithToolbarBase<CommandsConfiguration>
910
{
1011
public ExitCommand(string identifier, CommandsConfiguration configuration) : base(identifier, configuration) { }
11-
1212
public override RunResult Run()
1313
{
1414
if (Input.Arguments.Length > 0 && Input.Arguments.First().ToLower().StartsWith("y")) return new RunResult(this, Input, output: "exit program", RunResultStatus.Quit);

0 commit comments

Comments
 (0)