std.env
Functionality Overview
The env package provides information and functionalities related to the current process, including environment variables, command-line arguments, standard streams, and process termination. It also offers methods to interact with standard input, standard output, and standard error.
This package delivers cross-platform unified control capabilities, currently supporting Linux, macOS, and Windows platforms.
The package provides getStdErr(), getStdIn(), and getStdOut() for accessing these three standard streams.
- ConsoleReader encapsulates functionalities related to the standard input stream, allowing data to be read from standard input through its
readmethods. - ConsoleWriter encapsulates functionalities related to standard output and standard error streams. ConsoleWriter provides a series of
writemethods for writing data to standard output and standard error.
Standard input (stdin), standard output (stdout), and standard error (stderr) are three common streams in computer operating systems.
Standard input is the stream through which programs receive input data from users, typically from keyboard input. Standard output is the stream through which programs output results to users, usually displayed on screen. Standard error is the stream through which programs output error messages when errors occur, also typically displayed on screen.
In Unix/Linux systems, standard input, standard output, and standard error correspond to file descriptors 0, 1, and 2 respectively. Programs can use these file descriptors to read and write data. For example, redirection symbols can be used to redirect standard output to files or pipe standard error to another program's standard input.
API List
Classes
| Class Name | Functionality |
|---|---|
| ConsoleReader | Provides functionality to read characters or strings from standard input. |
| ConsoleWriter | Provides functionality to write characters or strings to standard output or standard error streams. |
Functions
| Function | Functionality |
|---|---|
| atExit() | Registers a callback function to be executed when the current process exits. |
| exit() | Terminates the process. |
| getCommand() | Retrieves the current process command. |
| getCommandLine() | Retrieves the current process command line. |
| getHomeDirectory() | Retrieves the path of the current process's home directory. |
| getProcessId() | Retrieves the current process ID. |
| getStdErr() | Retrieves the standard error stream of the current process. |
| getStdIn() | Retrieves the standard input stream of the current process. |
| getStdOut() | Retrieves the standard output stream of the current process. |
| getTempDirectory() | Retrieves the path of the current process's temporary directory. |
| getVariable() | Retrieves the value of a specified environment variable for the current process. |
| getVariables() | Retrieves all environment variables of the current process. |
| getWorkingDirectory() | Retrieves the working directory path of the current process. |
| removeVariable() | Removes an environment variable by its specified name. |
| setVariable() | Sets an environment variable pair for the current process. |
Exception Classes
| Exception Class | Functionality |
|---|---|
| EnvException | The exception class for the env package. |