-
Notifications
You must be signed in to change notification settings - Fork 0
Library Structure
RafaPear edited this page Jun 23, 2025
·
1 revision
CLILib is organized in a modular way to make the code easy to maintain, extend and understand. Below is an overview of the main components and their purpose.
Responsible for controlling the CLI lifecycle:
-
runtimeCLI()– start the interactive CLI with a prompt and continuous input -
runSingleCmd(cmd: String)– execute a single command -
runFromFile(file: String)– execute commands from a.ppcfile -
registerDefaultCommands()– register all built‑in commands viaCmdRegister
Central manager of all commands available in the system:
-
register(cmd)– register a command -
unregister(cmd)– remove a command -
registerAll(list)– register multiple commands -
find(alias)– search for a command by name/alias -
all()– return all registered commands
Defines how each command should be structured:
-
description,usage,aliases,run(args)are required -
minArgs,maxArgs,requiresFile, etc. are optional - All commands implement this interface
Allows creation, modification and lookup of global variables:
-
register(name, value)– create a variable -
get(name)– get a variable value -
modify(name, value)– change the value -
unregister(name)– remove a variable -
all()– return all variables
Enables basic math expressions with operators + - * / and parentheses.
Example:
val parser = ExprParser()
val result = parser.parse("3 + (2 * 5)")-
cmdParser(...)– interpret and execute chained commands using| -
replaceVars()– substitute variables ($a) with their values -
validateArgs(...)– validate argument count and files -
drawPrompt(),clearPrompt()– manipulate the terminal -
ProgressBar.kt– visual progress bar component -
Colors.kt– ANSI color codes for the terminal -
Global.kt– global constants (e.g.version,commentCode,root)
Demonstrates how to start the application and run scripts:
fun main() {
val app = App()
app.registerDefaultCommands()
app.runFromFile("Scripts/exampleScript.ppc")
}Made with ❤️ by Rafael Vermelho Pereira This project is under the MIT License · Contributions are welcome! 🤝 How to Contribute