Click or drag to resize

ArgumentsToArgs Method

Provides an array of arguments parsed from the given command using parsing rules similar to those used in POSIX environments.

Namespace: GSF.Console
Assembly: GSF.Core (in GSF.Core.dll) Version: 2.4.218-beta+101eee949414e414795e55a6e73d88938f0177b8
Syntax
public static string[] ToArgs(
	string command
)
View Source

Parameters

command  String
The command to be parsed.

Return Value

String
An array of arguments.
Remarks

This function processes a set of command line arguments using a simple set of rules based on those used in popular POSIX command shells. It is important to note that these rules do not apply to instances of the Arguments class or the ParseCommand(String) function.

The motivation for this function was to provide a more user-friendly set of rules by which to specify command-line arguments. This is of course helpful for the user who has to type the command-line arguments by hand, but it also ends up being useful for systems that have to programmatically escape arguments to be consumed by other command-line applications (see the Escape(String) function).

Also note that Windows has historically not provided a standard method for handling command-line arguments and that some of the command-line tools in Windows have rolled their own (potentially faulty) methods for doing so. More recently, Microsoft has provided the GetCommandLineArgs function for .NET applications to retrieve their own command line arguments using a standard format, but this function lacks the appropriate supporting functions for programmatically handling arbitrary command strings within an application. Furthermore, the rules for escaping spaces, quotes, and backslashes are very inconsistent, making it difficult to write a robust method for escaping individual arguments, let alone fully reproducing the same command parsing rules. For this reason, some programmers may be interested in using this method in conjunction with CommandLine for parsing their own command line arguments.

See Also