Zero Install .NET API 2.20.0
ZeroInstall.Commands.CliCommand Class Referenceabstract

Represents a command invoked via command-line arguments. More...

Inheritance diagram for ZeroInstall.Commands.CliCommand:
ZeroInstall.Commands.ScopedOperation ZeroInstall.Services.ServiceProvider ZeroInstall.Commands.Basic.AddRemoveFeedCommand ZeroInstall.Commands.Basic.Configure ZeroInstall.Commands.Basic.DefaultCommand ZeroInstall.Commands.Basic.Digest ZeroInstall.Commands.Basic.ExportHelp ZeroInstall.Commands.Basic.Fetch ZeroInstall.Commands.Basic.Import ZeroInstall.Commands.Basic.List ZeroInstall.Commands.Basic.ListFeeds ZeroInstall.Commands.Basic.Search ZeroInstall.Commands.Basic.Selection ZeroInstall.Commands.Basic.StoreMan.StoreSubCommand ZeroInstall.Commands.CliMultiCommand ZeroInstall.Commands.Desktop.Central ZeroInstall.Commands.Desktop.IntegrationCommand ZeroInstall.Commands.Desktop.Self.SelfSubCommand

Public Member Functions

virtual void Parse (IEnumerable< string > args)
 Parses command-line arguments and stores the result in the command. More...
 
abstract ExitCode Execute ()
 Executes the commands specified by the command-line arguments. Must call Parse first! More...
 
- Public Member Functions inherited from ZeroInstall.Commands.ScopedOperation
FeedUri GetCanonicalUri (string uri)
 Converts an interface or feed URI to its canonical representation. More...
 
- Public Member Functions inherited from ZeroInstall.Services.ServiceProvider
 ServiceProvider (ITaskHandler handler)
 Creates a new service provider. More...
 

Static Public Member Functions

static CliCommand Create (string? commandName, ICommandHandler handler)
 Creates a new CliCommand based on a name. More...
 
static CliCommand CreateAndParse (IEnumerable< string > args, ICommandHandler handler)
 Parses command-line arguments, automatically creating an appropriate CliCommand. More...
 
static ? string GetCommandName (ref IEnumerable< string > args)
 Determines the command name specified in the command-line arguments. More...
 

Protected Member Functions

 CliCommand (ICommandHandler handler)
 Creates a new command. More...
 
void FetchAll (IEnumerable< Implementation > implementations)
 Downloads a set of Implementations to the Store in parallel. More...
 
ParallelQuery< T > AsParallel< T > (IEnumerable< T > elements)
 Prepares the elements for parallel processing while respecting Config.MaxParallelDownloads and ITaskHandler.CancellationToken.
 
- Protected Member Functions inherited from ZeroInstall.Commands.ScopedOperation
 ScopedOperation (ITaskHandler handler)
 Creates a new command base. More...
 
Catalog GetCatalog ()
 Returns a merged view of all Catalogs specified by the configuration files. More...
 
FeedFindByShortName (string shortName)
 Uses Catalog.FindByShortName to find a Feed matching a specific short name. More...
 
void SelfUpdateCheck ()
 Periodically checks Zero Install itself for updates in a background process.
 

Static Protected Member Functions

static string SupportedValues< T > (params T[] values)
 Generates a localized instruction string describing multiple selectable values. More...
 
static string SupportedValues< T > ()
 Generates a localized instruction string describing multiple selectable enum values. More...
 
- Static Protected Member Functions inherited from ZeroInstall.Commands.ScopedOperation
static void StartCommandBackground (string command, params string[] args)
 Starts executing a command in a background process. Returns immediately. More...
 

Protected Attributes

readonly List< string > AdditionalArgs = new()
 Feeds to add, terms to search for, etc.
 

Package Attributes

readonly OptionSet Options = new()
 The command-line argument parser used to evaluate user input.
 

Static Package Attributes

static readonly string[] Names
 A list of command names (without alternatives) as used in command-line arguments in lower-case. More...
 

Properties

string???? FullName [get]
 The full name of this command (including sub-commands) as used in command-line arguments in lower-case.
 
abstract string Description [get]
 A short description of what this command does.
 
abstract string Usage [get]
 The additional arguments to be displayed after the command name in the help text.
 
virtual int AdditionalArgsMin [get]
 The minimum number of AdditionalArgs allowed. Checked in Parse.
 
virtual int AdditionalArgsMax [get]
 The maximum number of AdditionalArgs allowed. Checked in Parse.
 
string HelpText [get]
 The help text describing the available command-line options and their effects.
 
new ICommandHandler Handler [get]
 A callback object used when the the user needs to be asked questions or informed about download and IO tasks.
 
- Properties inherited from ZeroInstall.Services.ServiceProvider
virtual ITaskHandler Handler [get]
 A callback object used when the the user needs to be asked questions or informed about download and IO tasks.
 
virtual Config Config [get]
 User settings controlling network behaviour, solving, etc.
 
virtual IImplementationStore ImplementationStore = ImplementationStores.Default() [getset]
 Describes an object that allows the storage and retrieval of Implementation directories.
 
virtual IOpenPgp OpenPgp = Store.Trust.OpenPgp.Verifying() [getset]
 Provides access to an encryption/signature system compatible with the OpenPGP standard.
 
virtual IFeedCache FeedCache [get]
 Provides access to a cache of Feeds that were downloaded via HTTP(S).
 
virtual ITrustManager TrustManager [get]
 Methods for verifying signatures and user trust.
 
virtual IFeedManager FeedManager [get]
 Allows configuration of the source used to request Feeds.
 
virtual ICatalogManager CatalogManager [get]
 Provides access to remote and local Catalogs. Handles downloading, signature verification and caching.
 
virtual IPackageManager PackageManager [get]
 An external package manager that can install PackageImplementations.
 
virtual ISelectionCandidateProvider SelectionCandidateProvider [get]
 Generates SelectionCandidates for the Solver to choose among.
 
virtual ISolver Solver [get]
 Chooses a set of Implementations to satisfy the requirements of a program and its user.
 
virtual IFetcher Fetcher [get]
 Used to download missing Implementations.
 
virtual IExecutor Executor [get]
 Executes a Selections document as a program using dependency injection.
 
virtual ISelectionsManager SelectionsManager [get]
 Provides methods for filtering Selections.
 

Detailed Description

Represents a command invoked via command-line arguments.

Specific sub-classes of this class are used to handle a commands like "0install COMMAND [OPTIONS]".

Constructor & Destructor Documentation

◆ CliCommand()

ZeroInstall.Commands.CliCommand.CliCommand ( ICommandHandler  handler)
inlineprotected

Creates a new command.

Parameters
handlerA callback object used when the the user needs to be asked questions or informed about download and IO tasks.

Member Function Documentation

◆ Create()

static CliCommand ZeroInstall.Commands.CliCommand.Create ( string?  commandName,
ICommandHandler  handler 
)
static

Creates a new CliCommand based on a name.

Parameters
commandNameThe command name to look for; case-insensitive; can be null.
handlerA callback object used when the the user needs to be asked questions or informed about download and IO tasks.
Returns
The requested CliCommand or DefaultCommand if commandName was null.
Exceptions
OptionExceptioncommandName is an unknown command.
IOExceptionThere was a problem accessing a configuration file or one of the stores.
UnauthorizedAccessExceptionAccess to a configuration file or one of the stores was not permitted.
InvalidDataExceptionA configuration file is damaged.

◆ CreateAndParse()

static CliCommand ZeroInstall.Commands.CliCommand.CreateAndParse ( IEnumerable< string >  args,
ICommandHandler  handler 
)
inlinestatic

Parses command-line arguments, automatically creating an appropriate CliCommand.

Parameters
argsThe command-line arguments to be parsed.
handlerA callback object used when the the user needs to be asked questions or informed about download and IO tasks.
Returns
The newly created CliCommand after CliCommand.Parse has been called.
Exceptions
OperationCanceledExceptionThe user asked to see help information, version information, etc..
OptionExceptionargs contains unknown options or specified an unknown command.
IOExceptionA problem occurred while creating a directory.
UnauthorizedAccessExceptionCreating a directory is not permitted.
InvalidDataExceptionA configuration file is damaged.
FormatExceptionAn URI, local path, version number, etc. is invalid.

◆ Execute()

abstract ExitCode ZeroInstall.Commands.CliCommand.Execute ( )
pure virtual

Executes the commands specified by the command-line arguments. Must call Parse first!

Returns
The exit status code to end the process with.
Exceptions
OperationCanceledExceptionThe user canceled the task.
OptionExceptionThe number of arguments passed in on the command-line is incorrect.
WebExceptionA file could not be downloaded from the internet.
NotSupportedExceptionA file format, protocol, etc. is unknown or not supported.
IOExceptionA downloaded file could not be written to the disk or extracted or an external application or file required by the solver could not be accessed.
UnauthorizedAccessExceptionAn operation failed due to insufficient rights.
InvalidDataExceptionA problem occurred while deserializing an XML file.
SignatureExceptionThe signature data could not be handled for some reason.
FormatExceptionAn URI, local path, version number, etc. is invalid.
DigestMismatchExceptionAn Implementation's Archives don't match the associated ManifestDigest.
SolverExceptionThe ISolver was unable to provide Selections that fulfill the Requirements.
ImplementationNotFoundExceptionOne of the ImplementationBases is not cached yet.
ExecutorExceptionThe IExecutor was unable to process the Selections.

When inheriting this method is usually replaced.

Implemented in ZeroInstall.Commands.Basic.AddRemoveFeedCommand, ZeroInstall.Commands.Basic.Configure, ZeroInstall.Commands.Basic.DefaultCommand, ZeroInstall.Commands.Basic.Digest, ZeroInstall.Commands.Basic.Download, ZeroInstall.Commands.Basic.Export, ZeroInstall.Commands.Basic.ExportHelp, ZeroInstall.Commands.Basic.Fetch, ZeroInstall.Commands.Basic.Import, ZeroInstall.Commands.Basic.List, ZeroInstall.Commands.Basic.ListFeeds, ZeroInstall.Commands.Basic.Run, ZeroInstall.Commands.Basic.Search, ZeroInstall.Commands.Basic.Selection, ZeroInstall.Commands.Basic.StoreMan.List, ZeroInstall.Commands.Basic.StoreMan.Add, ZeroInstall.Commands.Basic.StoreMan.Copy, ZeroInstall.Commands.Basic.StoreMan.Export, ZeroInstall.Commands.Basic.StoreMan.Find, ZeroInstall.Commands.Basic.StoreMan.Remove, ZeroInstall.Commands.Basic.StoreMan.Verify, ZeroInstall.Commands.Basic.StoreMan.Manage, ZeroInstall.Commands.Basic.StoreMan.ListImplementations, ZeroInstall.Commands.Basic.StoreMan.Audit, ZeroInstall.Commands.Basic.StoreMan.Optimise, ZeroInstall.Commands.Basic.StoreMan.Purge, ZeroInstall.Commands.Basic.Update, ZeroInstall.Commands.CliMultiCommand, ZeroInstall.Commands.Desktop.AppCommand, ZeroInstall.Commands.Desktop.Central, ZeroInstall.Commands.Desktop.ImportApps, ZeroInstall.Commands.Desktop.ListApps, ZeroInstall.Commands.Desktop.RemoveAllApps, ZeroInstall.Commands.Desktop.RepairApps, ZeroInstall.Commands.Desktop.Self.Deploy, ZeroInstall.Commands.Desktop.Self.Remove, ZeroInstall.Commands.Desktop.Self.Update, ZeroInstall.Commands.Desktop.SyncApps, and ZeroInstall.Commands.Desktop.UpdateApps.

◆ FetchAll()

void ZeroInstall.Commands.CliCommand.FetchAll ( IEnumerable< Implementation implementations)
inlineprotected

Downloads a set of Implementations to the Store in parallel.

Parameters
implementationsThe Implementations to be downloaded.
Exceptions
OperationCanceledExceptionA download or IO task was canceled from another thread.
WebExceptionA file could not be downloaded from the internet.
NotSupportedExceptionA file format, protocol, etc. is unknown or not supported.
IOExceptionA downloaded file could not be written to the disk or extracted.
UnauthorizedAccessExceptionWrite access to IImplementationStore is not permitted.
DigestMismatchExceptionAn Implementation's Archives don't match the associated ManifestDigest.

◆ GetCommandName()

static ? string ZeroInstall.Commands.CliCommand.GetCommandName ( ref IEnumerable< string >  args)
inlinestatic

Determines the command name specified in the command-line arguments.

Parameters
argsThe command-line arguments to search for a command name. If a command is found it is removed from the collection.
Returns
The name of the command that was found or null if none was specified.

◆ Parse()

virtual void ZeroInstall.Commands.CliCommand.Parse ( IEnumerable< string >  args)
inlinevirtual

Parses command-line arguments and stores the result in the command.

Parameters
argsThe command-line arguments to be parsed.
Exceptions
OperationCanceledExceptionThe user asked to see help information, version information, etc..
OptionExceptionargs contains unknown options.
IOExceptionAn IO operation failed.
UnauthorizedAccessExceptionMore privileges are required.
UriFormatExceptionThe URI or local path specified is invalid.

Reimplemented in ZeroInstall.Commands.Basic.Export, ZeroInstall.Commands.Basic.Selection, ZeroInstall.Commands.CliMultiCommand, ZeroInstall.Commands.Desktop.IntegrationCommand, and ZeroInstall.Commands.Desktop.Self.Update.

◆ SupportedValues< T >() [1/2]

static string ZeroInstall.Commands.CliCommand.SupportedValues< T > ( )
staticprotected

Generates a localized instruction string describing multiple selectable enum values.

Template Parameters
TThe enum type to list values for.

◆ SupportedValues< T >() [2/2]

static string ZeroInstall.Commands.CliCommand.SupportedValues< T > ( params T[]  values)
staticprotected

Generates a localized instruction string describing multiple selectable values.

Parameters
valuesThe values to list.

Member Data Documentation

◆ Names

readonly string [] ZeroInstall.Commands.CliCommand.Names
staticpackage
Initial value:
=
{
Selection.Name, Download.Name, Update.Name, Run.Name, Import.Name, Export.Name, Search.Name, List.Name, CatalogMan.Name, Configure.Name, AddFeed.Name, RemoveFeed.Name, ListFeeds.Name, Digest.Name, StoreMan.Name,
Central.Name, AddApp.Name, RemoveApp.Name, RemoveAllApps.Name, IntegrateApp.Name, AddAlias.Name, ListApps.Name, UpdateApps.Name, RepairApps.Name, SyncApps.Name, ImportApps.Name, Self.Name
}
@ Run
Run the target application.

A list of command names (without alternatives) as used in command-line arguments in lower-case.


The documentation for this class was generated from the following files: