Jelajahi Sumber

added doc for Sys.command and sys.io.Process

Andy Li 9 tahun lalu
induk
melakukan
48104849b6
2 mengubah file dengan 42 tambahan dan 2 penghapusan
  1. 11 2
      std/Sys.hx
  2. 31 0
      std/sys/io/Process.hx

+ 11 - 2
std/Sys.hx

@@ -83,9 +83,18 @@ extern class Sys {
 	static function systemName() : String;
 
 	/**
-		Run the given command with the list of arguments. The command output will be printed on the same output as the current process.
+		Run the given command. The command output will be printed on the same output as the current process.
 		The current process will block until the command terminates and it will return the command result (0 if there was no error).
-		Read the [sys.io.Process] api for a more complete way to start background processes.
+
+		When `args` is not `null`, it will be used as the command arguments,
+		with shell meta-characters automatically escaped and quoted if needed.
+		`cmd` should be an executable name that can be located in the `PATH` environment variable, or a path to an executable.
+		
+		When `args` is not given or is `null`, no automatic escaping/quoting is performed.
+		`cmd` should include the command together with its arguments, formatted exactly as it would be when typed at the command line.
+		It can run executables, as well as shell commands that are not executables (e.g. on Windows: `dir`, `cd`, `echo` etc).
+
+		Read the `sys.io.Process` api for a more complete way to start background processes.
 	**/
 	static function command( cmd : String, ?args : Array<String> ) : Int;
 

+ 31 - 0
std/sys/io/Process.hx

@@ -27,10 +27,41 @@ extern class Process {
 	var stderr(default,null) : haxe.io.Input;
 	var stdin(default,null) : haxe.io.Output;
 
+	/**
+		Construct a `Process` object, which run the given command immediately.
+
+		When `args` is not `null`, it will be used as the command arguments,
+		with shell meta-characters automatically escaped and quoted if needed.
+		`cmd` should be an executable name that can be located in the `PATH` environment variable, or a path to an executable.
+		
+		When `args` is not given or is `null`, no automatic escaping/quoting is performed.
+		`cmd` should include the command together with its arguments, formatted exactly as it would be when typed at the command line.
+		It can run executables, as well as shell commands that are not executables (e.g. on Windows: `dir`, `cd`, `echo` etc).
+
+		`close()` should be called when the `Process` is no longer used.
+	*/
 	function new( cmd : String, ?args : Array<String> ) : Void;
+
+	/**
+		Return the process ID.
+	*/
 	function getPid() : Int;
+
+	/**
+		Block until the process exits and return the exit code of the process.
+		If the process has already exited, return the exit code immediately.
+	*/
 	function exitCode() : Int;
+
+	/**
+		Close the process handle and release the associated resources.
+		All `Process` fields should not be used after `close()` is called.
+	*/
 	function close() : Void;
+
+	/**
+		Kill the process.
+	*/
 	function kill() : Void;
 
 }