Class PowershellBuilder
- Namespace
- SunamoPS
- Assembly
- SunamoPS.dll
Builds PowerShell command scripts using a text builder, supporting cd, cmd /c, yt-dlp, and other commands.
public class PowershellBuilder
- Inheritance
-
PowershellBuilder
- Inherited Members
- Extension Methods
Constructors
PowershellBuilder(Func<bool, TextBuilderPS>)
Creates a new PowershellBuilder with the specified text builder factory.
public PowershellBuilder(Func<bool, TextBuilderPS> textBuilderFactory)
Parameters
textBuilderFactoryFunc<bool, TextBuilderPS>Factory function that creates a TextBuilderPS. The bool parameter controls list mode.
Properties
Git
Gets or sets the Git bash builder.
public IGitBashBuilderPS? Git { get; set; }
Property Value
Npm
Gets or sets the NPM bash builder.
public INpmBashBuilderPS? Npm { get; set; }
Property Value
TextBuilder
Gets or sets the text builder used for constructing commands.
public TextBuilderPS TextBuilder { get; set; }
Property Value
Methods
AddArg(string, string)
Adds an argument name-value pair to the current command.
public void AddArg(string argName, string argValue)
Parameters
AddRaw(string)
Adds raw text to the current command without a newline. Automatically prepends configured prefix.
public void AddRaw(string text)
Parameters
textstringRaw text to append.
AddRawLine(string)
Adds raw text followed by a newline.
public void AddRawLine(string text = "")
Parameters
textstringRaw text to append as a line.
Cd(string)
Changes directory to the specified path.
public void Cd(string path)
Parameters
pathstringTarget directory path.
Clear()
Clears all accumulated commands.
public void Clear()
CmdC(string)
Adds a cmd /c command.
public void CmdC(string command)
Parameters
commandstringCommand to execute via cmd /c.
Create(Func<bool, TextBuilderPS>)
Creates a new PowershellBuilder instance.
public static PowershellBuilder Create(Func<bool, TextBuilderPS> textBuilderFactory)
Parameters
textBuilderFactoryFunc<bool, TextBuilderPS>Factory function for creating a TextBuilderPS.
Returns
- PowershellBuilder
New PowershellBuilder instance.
RemoveItem(string)
Adds a Remove-Item command with -Force flag.
public void RemoveItem(string path)
Parameters
pathstringPath of the item to remove.
ToList()
Converts accumulated commands to a list of strings.
public List<string> ToList()
Returns
ToString()
Returns all accumulated commands as a single string.
public override string ToString()
Returns
- string
String representation of all commands.
WithPath(CommandWithPath, string)
Adds a command with a path argument.
public void WithPath(CommandWithPath commandWithPath, string path)
Parameters
commandWithPathCommandWithPathType of command.
pathstringPath argument for the command.
YtDlp(string)
Adds a yt-dlp download command.
public void YtDlp(string url)
Parameters
urlstringURL to download.