Table of Contents

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

textBuilderFactory Func<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

IGitBashBuilderPS

Npm

Gets or sets the NPM bash builder.

public INpmBashBuilderPS? Npm { get; set; }

Property Value

INpmBashBuilderPS

TextBuilder

Gets or sets the text builder used for constructing commands.

public TextBuilderPS TextBuilder { get; set; }

Property Value

TextBuilderPS

Methods

AddArg(string, string)

Adds an argument name-value pair to the current command.

public void AddArg(string argName, string argValue)

Parameters

argName string

Name of the argument.

argValue string

Value of the argument.

AddRaw(string)

Adds raw text to the current command without a newline. Automatically prepends configured prefix.

public void AddRaw(string text)

Parameters

text string

Raw text to append.

AddRawLine(string)

Adds raw text followed by a newline.

public void AddRawLine(string text = "")

Parameters

text string

Raw text to append as a line.

Cd(string)

Changes directory to the specified path.

public void Cd(string path)

Parameters

path string

Target directory path.

Clear()

Clears all accumulated commands.

public void Clear()

CmdC(string)

Adds a cmd /c command.

public void CmdC(string command)

Parameters

command string

Command to execute via cmd /c.

Create(Func<bool, TextBuilderPS>)

Creates a new PowershellBuilder instance.

public static PowershellBuilder Create(Func<bool, TextBuilderPS> textBuilderFactory)

Parameters

textBuilderFactory Func<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

path string

Path of the item to remove.

ToList()

Converts accumulated commands to a list of strings.

public List<string> ToList()

Returns

List<string>

List of command strings.

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

commandWithPath CommandWithPath

Type of command.

path string

Path argument for the command.

YtDlp(string)

Adds a yt-dlp download command.

public void YtDlp(string url)

Parameters

url string

URL to download.