-
Notifications
You must be signed in to change notification settings - Fork 0
iash class
#include "iash.h"
The iash class provides an internal shell in a terminal application.
Version: 0.2 "Firmament"
Introduced in v0.1 "Dawn"
iash (std::string app_nm="iash",bool appInPrompt=true)
The constructor for the iash class.
Since v0.2 "Firmament":It sets all of the internal variables and imports the environment from the last run.
-
app_nm
: The name of your application. -
appInPrompt
: Whether or not the application name appears in command prompts
Introduced in v0.1 "Dawn"
void setAppName (std::string app_nm)
Changes the name of the application.
-
app_nm
: The new name of the application.
Introduced in v0.1 "Dawn"
void useAppNameInPrompt (bool appInPrompt)
Sets whether the application name is used in the command prompt.
-
appInPrompt
: Whether or not to use the app name in command prompts.
Introduced in v0.1 "Dawn"
std::vector<std::string> getCmdLine ()
Prompts a command line, parses the input, and returns it as a vector of strings.
A vector of strings that contains the command line. This includes:
- The command itself
- All arguments to the command
- All options to the command
If this function returns a vector whose first element is "iash"
, ignore it (i.e. do not call cmdNotFound()
. This command is used to invoke the shell debugger.
Introduced in v0.1 "Dawn"
std::vector<std::string> getLast ()
Returns the command line from the last command prompt. This does not prompt a new line.
The vector from the last command prompt.
Introduced in v0.1. "Dawn"
std::vector<std::string> getOptions ()
Returns a vector containing all of the options passed at the last command prompt. This does not prompt a new line.
Single-letter options are denoted by a single -
, option strings are denoted by --
.
A vector containing all of the options passed at the last prompt, without the minus characters (for example, -a
would appear as a
). Long single-letter option sequences (such as -abcdef
) are split into individual options (a
, b
, c
, d
, e
, f
).
Introduced in v0.1 "Dawn"
void clear ()
Clears the command buffer. The getLast()
and cmdNotFound()
functions will not work after calling this function (until a new command line has been prompted and processed).
iash provides a builtin environment variable system. Every iash shell has various builtin environment variables, for a list of those see Standard Environment Variables.
Introduced in v0.1 "Dawn"
std::string getEnv_string (std::string name)
int getEnv_int (std::string name)
float getEnv_float (std::string name)
bool getEnv_bool (std::string name)
Gets an iash environment variable in various forms. The return type is indicated by what follows the underscore.
-
name
: The name of the variable.
The environment variable, if it exists. Note that the functions that return types other than std::string
may not function properly if the variable cannot be translated into that type. The bool function will return false if the variable is something other than "true" is contained in the variable.
Introduced in v0.1 "Dawn"
void setEnv (std::string name, std::string value)
void setEnv (std::string name, int value)
void setEnv (std::string name, float value)
void setEnv (std::string name, bool value)
Sets environment variable name
, if it exists.
-
name
: The name of the environment variable. -
value
: The value to set the environment variable to.
Introduced in v0.1 "Dawn"
void rmenv (std::string name)
Removes variable name
from the environment, provided:
- it exists
- it is not a required variable (begins with
IASH_
)
-
name
: The name of the environment variable to remove.
Introduced in v0.2 "Firmament"
bool saveEnv ()
bool saveEnv (std::string filepath)
Saves the environment to file. If no file is specified, the file is $IASH_CONFIG_PATH/iashenv
.
-
filepath
: The file to save the environment to. Note that currently, iash does not support automatic loading from paths other than$IASH_CONFIG_PATH/iashenv
.
True if successful, false if not.
Introduced in v0.2 "Firmament"
bool loadEnv ()
bool loadEnv (std::string filepath)
Loads the environment from file. If no file is specified, the file is $IASH_CONFIG_PATH/iashenv
.
-
filepath
: The file to load from.
True if successful, false if not.
Introduced in v0.1 "Dawn"
void cmdNotFound()
Prints a command-not-found message for the command currently in the command buffer.
Introduced in v0.1 "Dawn"
void clearScreen()
Clears the screen.
iash wiki -- Go home
-
Current version
- API reference
- Runtime documentation
-
Older versions
- API reference
- Runtime documentation
- Posting to the Issue Tracker