C# 클래스 CommandLine.UI

Main class for interacting via the command-line. Handles the definition and parsing of command-line arguments, and the display of usage and help messages.
파일 보기 프로젝트 열기: agardiner/hfmcmd

공개 프로퍼티들

프로퍼티 타입 설명
Definition Definition
Interrupted bool
IsRedirected bool

보호된 프로퍼티들

프로퍼티 타입 설명
_log log4net.ILog

공개 메소드들

메소드 설명
AddFlagArgument ( string key, string desc ) : FlagArgument

Convenience method for defining a new flag argument.

AddFlagArgument ( string key, string desc, Argument onParse ) : FlagArgument

Convenience method for defining a new flag argument.

AddKeywordArgument ( string key, string desc ) : KeywordArgument

Convenience method for defining a new keyword argument.

AddKeywordArgument ( string key, string desc, Argument onParse ) : KeywordArgument

Convenience method for defining a new keyword argument.

AddPositionalArgument ( string key, string desc ) : PositionalArgument

Convenience method for defining a new positional argument.

AddPositionalArgument ( string key, string desc, Argument onParse ) : PositionalArgument

Convenience method for defining a new positional argument.

ClassifyArguments ( IEnumerable args ) : int

Classifies the supplied list of arguments, returning a count of the number of positional arguments found.

ClearArguments ( ) : void

Clear existing arguments from the definition.

ClearLine ( ) : void

Clears the last text written to the console using Write. Note that this may be more than a single line of text, if the window width is less than the length of the string written.

DisplayTitle ( TextWriter console ) : void

Displays the application title, version etc.

DisplayUsage ( TextWriter console, object>.Dictionary args ) : void

Displays a usgae message, based on the allowed arguments and purpose represented by this class.

Parse ( IEnumerable args ) : object>.Dictionary

Parses the supplied set of arg strings using the list of Argument definitions maintained by this command-line UI instance.

ReadLine ( string prompt ) : string

For completeness - read a line of input from the console.

ReadPassword ( string prompt ) : string

Reads a password from the command-line, echoing * for each keypress.

RegisterCtrlHandler ( ) : Win32.Handler

This method registers this class as a handler for Ctrl-C etc events in the console. It returns a handle to the handler, which should be referenced via the following at the end of the program Main method: GC.KeepAlive(hr);

UI ( string help ) : System

Constructor; requires a purpose for the program whose args we are parsing.

WithColor ( ConsoleColor color, System.Action op ) : void

Performs the specified operation +op+ with the console color temporarily changed to +color+. On completion of the operation, the color is reset to the original color.

Write ( string line ) : void

Writes a partial line of text to the console, without moving to the next line.

WriteLine ( ) : void

Writes a blank line to the console.

WriteLine ( string text ) : void

Writes a line of text to the console, ensuring lines the same width as the console don't output an unnecessary new-line.

보호된 메소드들

메소드 설명
OutputArg ( Argument arg, TextWriter console ) : void

비공개 메소드들

메소드 설명
CtrlHandler ( EInterruptTypes ctrlType ) : bool

Handler to receive control events, such as Ctrl-C and logoff and shutdown events. As a minimum, this logs the event, so that a record of why the process exited is maintained.

메소드 상세

AddFlagArgument() 공개 메소드

Convenience method for defining a new flag argument.
public AddFlagArgument ( string key, string desc ) : FlagArgument
key string
desc string
리턴 FlagArgument

AddFlagArgument() 공개 메소드

Convenience method for defining a new flag argument.
public AddFlagArgument ( string key, string desc, Argument onParse ) : FlagArgument
key string
desc string
onParse Argument
리턴 FlagArgument

AddKeywordArgument() 공개 메소드

Convenience method for defining a new keyword argument.
public AddKeywordArgument ( string key, string desc ) : KeywordArgument
key string
desc string
리턴 KeywordArgument

AddKeywordArgument() 공개 메소드

Convenience method for defining a new keyword argument.
public AddKeywordArgument ( string key, string desc, Argument onParse ) : KeywordArgument
key string
desc string
onParse Argument
리턴 KeywordArgument

AddPositionalArgument() 공개 메소드

Convenience method for defining a new positional argument.
public AddPositionalArgument ( string key, string desc ) : PositionalArgument
key string
desc string
리턴 PositionalArgument

AddPositionalArgument() 공개 메소드

Convenience method for defining a new positional argument.
public AddPositionalArgument ( string key, string desc, Argument onParse ) : PositionalArgument
key string
desc string
onParse Argument
리턴 PositionalArgument

ClassifyArguments() 공개 메소드

Classifies the supplied list of arguments, returning a count of the number of positional arguments found.
public ClassifyArguments ( IEnumerable args ) : int
args IEnumerable
리턴 int

ClearArguments() 공개 메소드

Clear existing arguments from the definition.
public ClearArguments ( ) : void
리턴 void

ClearLine() 공개 메소드

Clears the last text written to the console using Write. Note that this may be more than a single line of text, if the window width is less than the length of the string written.
public ClearLine ( ) : void
리턴 void

DisplayTitle() 공개 메소드

Displays the application title, version etc.
public DisplayTitle ( TextWriter console ) : void
console System.IO.TextWriter
리턴 void

DisplayUsage() 공개 메소드

Displays a usgae message, based on the allowed arguments and purpose represented by this class.
public DisplayUsage ( TextWriter console, object>.Dictionary args ) : void
console System.IO.TextWriter
args object>.Dictionary
리턴 void

OutputArg() 보호된 메소드

protected OutputArg ( Argument arg, TextWriter console ) : void
arg Argument
console System.IO.TextWriter
리턴 void

Parse() 공개 메소드

Parses the supplied set of arg strings using the list of Argument definitions maintained by this command-line UI instance.
public Parse ( IEnumerable args ) : object>.Dictionary
args IEnumerable
리턴 object>.Dictionary

ReadLine() 공개 메소드

For completeness - read a line of input from the console.
public ReadLine ( string prompt ) : string
prompt string
리턴 string

ReadPassword() 공개 메소드

Reads a password from the command-line, echoing * for each keypress.
public ReadPassword ( string prompt ) : string
prompt string
리턴 string

RegisterCtrlHandler() 공개 정적인 메소드

This method registers this class as a handler for Ctrl-C etc events in the console. It returns a handle to the handler, which should be referenced via the following at the end of the program Main method: GC.KeepAlive(hr);
public static RegisterCtrlHandler ( ) : Win32.Handler
리턴 Win32.Handler

UI() 공개 메소드

Constructor; requires a purpose for the program whose args we are parsing.
public UI ( string help ) : System
help string
리턴 System

WithColor() 공개 메소드

Performs the specified operation +op+ with the console color temporarily changed to +color+. On completion of the operation, the color is reset to the original color.
public WithColor ( ConsoleColor color, System.Action op ) : void
color ConsoleColor
op System.Action
리턴 void

Write() 공개 메소드

Writes a partial line of text to the console, without moving to the next line.
public Write ( string line ) : void
line string
리턴 void

WriteLine() 공개 메소드

Writes a blank line to the console.
public WriteLine ( ) : void
리턴 void

WriteLine() 공개 메소드

Writes a line of text to the console, ensuring lines the same width as the console don't output an unnecessary new-line.
public WriteLine ( string text ) : void
text string
리턴 void

프로퍼티 상세

Definition 공개적으로 프로퍼티

public Definition,CommandLine Definition
리턴 Definition

Interrupted 공개적으로 정적으로 프로퍼티

Static public flag indicating that the application is to terminate immediately, e.g. in response to a Ctrl-C or Logoff event. Any long- running command should check this flag periodically and attempt to abort gracefully.
public static bool Interrupted
리턴 bool

IsRedirected 공개적으로 정적으로 프로퍼티

public static bool IsRedirected
리턴 bool

_log 보호되어 있는 정적으로 프로퍼티

protected static ILog,log4net _log
리턴 log4net.ILog