Phasor 2.2.0
Stack VM based Programming Language
Loading...
Searching...
No Matches
src/CLI/utils/Shell.dox File Reference

Functions

fn trim (s:string) -> string
 A simple interactive shell implementation for the Phasor VM.
fn starts_with (input:string, prefix:string) -> bool
 Checks if a string starts with a specific prefix.
fn main ()
 The main execution loop of the Phasor Shell.

Function Documentation

◆ main()

fn main ( )

The main execution loop of the Phasor Shell.

  • The main function performs the following steps in an infinite loop:
  1. Displays a prompt containing the current working directory (fcd).
  2. Reads user input from standard input (gets).
  3. Trims the input and checks for the "exit" command.
  4. Dispatches the command to the underlying operating system (sys_execute).
  • Returns
    int Returns 0 on successful termination via 'exit'.

Definition at line 38 of file Shell.dox.

◆ starts_with()

fn starts_with ( input:string ,
prefix:string  ) -> bool

Checks if a string starts with a specific prefix.

  • Performs a length-guarded comparison of the beginning of the input string against the provided prefix string.
  • Parameters
    inputThe string to search within.
    prefixThe substring to look for at the start.
    Returns
    bool True if input starts with prefix, false otherwise.

Definition at line 26 of file Shell.dox.

◆ trim()

fn trim ( s:string ) -> string

A simple interactive shell implementation for the Phasor VM.

  • This script provides a basic Command Line Interface (CLI) that allows users to execute system commands, navigate the file system, and interact with the Phasor environment. It demonstrates the use of standard library modules for I/O, string manipulation, and system execution.

Removes leading and trailing whitespace from a string.

  • Iterates through the input string to strip space characters (' ') from both the beginning and the end of the text.
  • Parameters
    sThe input string to be trimmed.
    Returns
    string A new string with whitespace removed.

Definition at line 16 of file Shell.dox.