Show / Hide Table of Contents

Class CliCommand

Represents a command invoked via command-line arguments.

Inheritance
Object
ServiceProvider
ScopedOperation
CliCommand
AddRemoveFeedCommand
Configure
DefaultCommand
Digest
ExportHelp
Fetch
Import
List
ListFeeds
Search
Selection
StoreMan.StoreSubCommand
TrustMan.TrustSubCommand
CliMultiCommand
Central
IntegrationCommand
ListApps
Self.SelfSubCommand
Inherited Members
ScopedOperation.GetCanonicalUri(String)
ScopedOperation.GetCatalog()
ScopedOperation.FindByShortName(String)
ScopedOperation.BackgroundSelfUpdate()
ScopedOperation.StartCommandBackground(String, String[])
ScopedOperation.MinimumNetworkUseForBackgroundSelfUpdate
ServiceProvider.TrySolveOffline(Requirements)
ServiceProvider.Config
ServiceProvider.ImplementationStore
ServiceProvider.OpenPgp
ServiceProvider.FeedCache
ServiceProvider.TrustManager
ServiceProvider.FeedManager
ServiceProvider.CatalogManager
ServiceProvider.PackageManager
ServiceProvider.SelectionCandidateProvider
ServiceProvider.Solver
ServiceProvider.Fetcher
ServiceProvider.Executor
ServiceProvider.SelectionsManager
Namespace: ZeroInstall.Commands
Assembly: 0install.dll
Syntax
public abstract class CliCommand : ScopedOperation
Remarks

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

Constructors

CliCommand(ICommandHandler)

Creates a new command.

Declaration
protected CliCommand(ICommandHandler handler)
Parameters
Type Name Description
ICommandHandler handler

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

Fields

AdditionalArgs

Feeds to add, terms to search for, etc.

Declaration
protected readonly List<string> AdditionalArgs
Field Value
Type Description
List<String>

Options

The command-line argument parser used to evaluate user input.

Declaration
protected readonly OptionSet Options
Field Value
Type Description
NDesk.Options.OptionSet

Properties

AdditionalArgsMax

The maximum number of AdditionalArgs allowed. Checked in Parse(IReadOnlyList<String>).

Declaration
protected virtual int AdditionalArgsMax { get; }
Property Value
Type Description
Int32

AdditionalArgsMin

The minimum number of AdditionalArgs allowed. Checked in Parse(IReadOnlyList<String>).

Declaration
protected virtual int AdditionalArgsMin { get; }
Property Value
Type Description
Int32

Description

A short description of what this command does.

Declaration
public abstract string Description { get; }
Property Value
Type Description
String

FullName

The full name of this command (including sub-commands) as used in command-line arguments in lower-case.

Declaration
public string FullName { get; }
Property Value
Type Description
String

Handler

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

Declaration
public ICommandHandler Handler { get; }
Property Value
Type Description
ICommandHandler

HelpText

The help text describing the available command-line options and their effects.

Declaration
protected string HelpText { get; }
Property Value
Type Description
String

ImplementationsInReadOnlyStores

Indicates whether there are currently any implementations stored in read-only IImplementationStores.

Declaration
protected bool ImplementationsInReadOnlyStores { get; }
Property Value
Type Description
Boolean

Usage

The additional arguments to be displayed after the command name in the help text.

Declaration
public abstract string Usage { get; }
Property Value
Type Description
String

Methods

AsParallel<T>(IEnumerable<T>)

Prepares the elements for parallel processing while respecting MaxParallelDownloads and CancellationToken.

Declaration
protected ParallelQuery<T> AsParallel<T>(IEnumerable<T> elements)
Parameters
Type Name Description
IEnumerable<T> elements
Returns
Type Description
ParallelQuery<T>
Type Parameters
Name Description
T

Create(String, ICommandHandler)

Creates a new CliCommand based on a name.

Declaration
public static CliCommand Create(string commandName, ICommandHandler handler)
Parameters
Type Name Description
String commandName

The command name to look for; case-insensitive; can be null.

ICommandHandler handler

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

Returns
Type Description
CliCommand

The requested CliCommand or DefaultCommand if commandName was null.

Exceptions
Type Condition
NDesk.Options.OptionException

commandName is an unknown command.

IOException

There was a problem accessing a configuration file or one of the stores.

UnauthorizedAccessException

Access to a configuration file or one of the stores was not permitted.

InvalidDataException

A configuration file is damaged.

CreateAndParse(IReadOnlyList<String>, ICommandHandler)

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

Declaration
public static CliCommand CreateAndParse(IReadOnlyList<string> args, ICommandHandler handler)
Parameters
Type Name Description
IReadOnlyList<String> args

The command-line arguments to be parsed.

ICommandHandler handler

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

Returns
Type Description
CliCommand

The newly created CliCommand after Parse(IReadOnlyList<String>) has been called.

Exceptions
Type Condition
OperationCanceledException

The user asked to see help information, version information, etc..

NDesk.Options.OptionException

args contains unknown options or specified an unknown command.

IOException

A problem occurred while creating a directory.

UnauthorizedAccessException

Creating a directory is not permitted.

InvalidDataException

A configuration file is damaged.

FormatException

An URI, local path, version number, etc. is invalid.

Execute()

Executes the commands specified by the command-line arguments. Must call Parse(IReadOnlyList<String>) first!

Declaration
public abstract ExitCode Execute()
Returns
Type Description
ExitCode

The exit status code to end the process with.

Remarks

When inheriting this method is usually replaced.

Exceptions
Type Condition
OperationCanceledException

The user canceled the task.

NDesk.Options.OptionException

The number of arguments passed in on the command-line is incorrect.

WebException

A file could not be downloaded from the internet.

NotSupportedException

A file format, protocol, etc. is unknown or not supported.

IOException

A 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.

UnauthorizedAccessException

An operation failed due to insufficient rights.

InvalidDataException

A problem occurred while deserializing an XML file.

SignatureException

The signature data could not be handled for some reason.

FormatException

An URI, local path, version number, etc. is invalid.

DigestMismatchException

An Implementation's Archives don't match the associated ManifestDigest.

SolverException

The ISolver was unable to provide Selections that fulfill the Requirements.

ImplementationNotFoundException

One of the ImplementationBases is not cached yet.

ExecutorException

The IExecutor was unable to process the Selections.

FetchAll(IEnumerable<Implementation>)

Downloads a set of Implementations to the ZeroInstall.Store in parallel.

Declaration
protected void FetchAll(IEnumerable<Implementation> implementations)
Parameters
Type Name Description
IEnumerable<Implementation> implementations

The Implementations to be downloaded.

Exceptions
Type Condition
OperationCanceledException

A download or IO task was canceled from another thread.

WebException

A file could not be downloaded from the internet.

NotSupportedException

A file format, protocol, etc. is unknown or not supported.

IOException

A downloaded file could not be written to the disk or extracted.

UnauthorizedAccessException

Write access to IImplementationStore is not permitted.

DigestMismatchException

An Implementation's Archives don't match the associated ManifestDigest.

GetCommandName(ref IReadOnlyList<String>)

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

Declaration
public static string GetCommandName(ref IReadOnlyList<string> args)
Parameters
Type Name Description
IReadOnlyList<String> args

The command-line arguments to search for a command name. The collection is replaced with a copy with the command removed from it.

Returns
Type Description
String

The name of the command that was found or null if none was specified.

Parse(IReadOnlyList<String>)

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

Declaration
public virtual void Parse(IReadOnlyList<string> args)
Parameters
Type Name Description
IReadOnlyList<String> args

The command-line arguments to be parsed.

Exceptions
Type Condition
OperationCanceledException

The user asked to see help information, version information, etc..

NDesk.Options.OptionException

args contains unknown options.

IOException

An IO operation failed.

UnauthorizedAccessException

More privileges are required.

UriFormatException

The URI or local path specified is invalid.

SupportedValues<T>()

Generates a localized instruction string describing multiple selectable enum values.

Declaration
protected static string SupportedValues<T>()
Returns
Type Description
String
Type Parameters
Name Description
T

The enum type to list values for.

SupportedValues<T>(T[])

Generates a localized instruction string describing multiple selectable values.

Declaration
protected static string SupportedValues<T>(params T[] values)
Parameters
Type Name Description
T[] values

The values to list.

Returns
Type Description
String
Type Parameters
Name Description
T
In This Article
Back to top Copyright Bastian Eicher et al