22 internal enum WinGetAction
38 return _arguments.Trim();
47 return string.IsNullOrWhiteSpace(_arguments);
51 private readonly WinGetAction _action;
53 private string _arguments;
66 internal WinGetArguments(
string baseCmd, WinGetAction action = WinGetAction.Unspecified)
333 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(cmd,
"cmd");
335 cmd = cmd.ToLower().Trim();
336 if (cmd.StartsWith(
"winget"))
338#if NETCOREAPP3_1_OR_GREATER
341 cmd = cmd.Substring(6);
366 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(custom,
"custom");
368 _arguments += $
" {custom.ToLower().Trim()}";
392 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(query,
"query");
394 _arguments += $
" --query \"{query}\"";
415 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(source,
"source");
417 _arguments += $
" --source \"{source}\"";
441 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(file,
"file");
445 case WinGetAction.Hash:
446 _arguments += $
" --file \"{file}\"";
448 case WinGetAction.Import:
449 _arguments += $
" --import-file \"{file}\"";
451 case WinGetAction.Export:
452 _arguments += $
" --output \"{file}\"";
479 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(directory,
"directory");
484#if NETCOREAPP3_1_OR_GREATER
485 while (directory.EndsWith(
'\\'))
487 directory = directory[..^1];
490 while (directory.EndsWith(
"\\"))
492 directory = directory.Substring(0, directory.Length - 1);
498 case WinGetAction.Download:
499 _arguments += $
" --download-directory \"{directory}\"";
523 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(query,
"query");
525 _arguments += $
" --enable \"{query}\"";
546 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(query,
"query");
548 _arguments += $
" --disable \"{query}\"";
572 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(name,
"name");
574 _arguments += $
" --name \"{name}\"";
598 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(arg,
"arg");
600 _arguments += $
" --arg \"{arg}\"";
624 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(type,
"type");
626 _arguments += $
" --type \"{type}\"";
647 ArgsHelper.ThrowIfStringIsNullOrWhiteSpace(version,
"version");
649 _arguments += $
" --version \"{version}\"";
667 ArgsHelper.ThrowIfObjectIsNull(version,
"version");
669 _arguments += $
" --version \"{version.ToString()}\"";
681 _arguments += $
" --version";
693 _arguments +=
" --exact";
705 _arguments +=
" --silent";
717 _arguments +=
" --all";
729 _arguments +=
" --include-unknown";
741 _arguments +=
" --accept-source-agreements";
753 _arguments +=
" --accept-package-agreements";
765 _arguments +=
" --ignore-unavailable";
777 _arguments +=
" --installed";
789 _arguments +=
" --blocking";
801 _arguments +=
" --force";
813 _arguments +=
" --info";
821 return _arguments.Trim();
Represents a winget arguments string for different winget actions.
static WinGetArguments WinGet()
Creates a new winget arguments object with no base cmd. Used for direct callin of the winget cmd with...
WinGetArguments Disable(string query)
Adds a disable action to the arguments.
static WinGetArguments SourceUpdate()
Creates a new winget arguments object with "source update" as the base cmd.
WinGetArguments All()
Adds the '–all' flag to the arguments.
WinGetArguments Blocking()
Adds the '–blocking' flag to the arguments.
WinGetArguments Name(string name)
Adds name data to the arguments.
WinGetArguments Installed()
Adds the '–installed' flag to the arguments.
static WinGetArguments PinAdd()
Creates a new winget arguments object with "pin add" as the base cmd.
WinGetArguments Version()
Adds a version query to the arguments.
WinGetArguments Custom(string custom)
Adds a custom flag/parameter to the arguments.
WinGetArguments Force()
Adds the '–force' flag to the arguments.
WinGetArguments IgnoreUnavailable()
Adds the '–ignore-unavailable' flag to the arguments.
static WinGetArguments Import()
Creates a new winget arguments object with "import" as the base cmd.
static WinGetArguments SettingsExport()
Creates a new winget arguments object with "settings export" as the base cmd.
WinGetArguments Silent()
Adds the '–silent' flag to the arguments.
string Arguments
Gets the generated arguments.
static WinGetArguments List()
Creates a new winget arguments object with "list" as the base cmd.
WinGetArguments Arg(string arg)
Adds arg (Source argument) data to the arguments.
static WinGetArguments Settings()
Creates a new winget arguments object with "settings" as the base cmd.
static WinGetArguments CustomCmd(string cmd)
Creates a new winget arguments object with a custom base cmd.
WinGetArguments Type(string type)
Adds type data to the arguments.
WinGetArguments IncludeUnknown()
Adds the '–include-unknown' flag to the arguments.
WinGetArguments Info()
Adds the '–info' flag to the arguments.
static WinGetArguments PinList()
Creates a new winget arguments object with "pin list" as the base cmd.
static WinGetArguments Search()
Creates a new winget arguments object with "search" as the base cmd.
WinGetArguments Query(string query)
Adds a query to the arguments.
WinGetArguments Enable(string query)
Adds a enable action to the arguments.
WinGetArguments AcceptSourceAgreements()
Adds the '–accept-source-agreements' flag to the arguments.
WinGetArguments AcceptPackageAgreements()
Adds the '–accept-package-agreements' flag to the arguments.
WinGetArguments Source(string source)
Adds a source query to the arguments.
bool IsEmpty
Gets if the object is empty.
static WinGetArguments SourceReset()
Creates a new winget arguments object with "source reset" as the base cmd.
WinGetArguments Exact()
Adds the '–exact' flag to the arguments.
static WinGetArguments PinRemove()
Creates a new winget arguments object with "pin remove" as the base cmd.
override string ToString()
static WinGetArguments SourceAdd()
Creates a new winget arguments object with "source add" as the base cmd.
static WinGetArguments SourceExport()
Creates a new winget arguments object with "source export" as the base cmd.
WinGetArguments File(string file)
Adds a file path to the arguments.
static WinGetArguments Repair()
Creates a new winget arguments object with "repair" as the base cmd.
static WinGetArguments Download()
Creates a new winget arguments object with "download" as the base cmd.
static WinGetArguments Hash()
Creates a new winget arguments object with "hash" as the base cmd.
WinGetArguments Version(Version version)
Adds a version query to the arguments.
static WinGetArguments Uninstall()
Creates a new winget arguments object with "uninstall" as the base cmd.
WinGetArguments Directory(string directory)
Adds a directory path to the arguments.
static WinGetArguments SourceRemove()
Creates a new winget arguments object with "source remove" as the base cmd.
static WinGetArguments Export()
Creates a new winget arguments object with "export" as the base cmd.
static WinGetArguments Upgrade()
Creates a new winget arguments object with "upgrade" as the base cmd.
static WinGetArguments PinReset()
Creates a new winget arguments object with "pin reset" as the base cmd.
static WinGetArguments Install()
Creates a new winget arguments object with "install" as the base cmd.
WinGetArguments Version(string version)
Adds a version query to the arguments.
Interface for all winget related objects.