01_hello_cli
Example 01: Hello CLI
The absolute basics. Writing a terminal program.
This example demonstrates the bare minimum structure of a BoredOS application that outputs text to the standard output (usually the Terminal executing the binary).
Concepts Introduced
- Including
stdlib.hfor basic IO. - The
main()entry point. - Using
printf()for formatted output. - Declaring app metadata via source annotations.
The Code (src/userland/cli/hello_world.c)
// BOREDOS_APP_DESC: Hello World — a minimal CLI demo.
#include <stdlib.h>
int main(int argc, char **argv) {
// Standard library initialization is handled automatically by crt0.asm
// Print a simple string to the terminal
printf("Hello, World from BoredOS Userland!\n");
// Print some formatted data
int favorite_number = 67;
printf("Did you know my favorite number is %d?\n", favorite_number);
// Returning from main automatically terminates the process cleanly
return 0;
}
How it Works
#include <stdlib.h>: We include the SDK's standard library header which gives us access toprintf.int main(...): Every process begins execution here (managed transparently bycrt0.asm).printf(...): The SDK routes this call internally directly to theSYS_WRITEsystem call, making it available on the terminal.return 0: A successful exit code.BOREDOS_APP_DESC/BOREDOS_APP_ICONS: These comment annotations are read by the build system (gen_userland_note.sh) and embedded as aboredos_app_metadata_tNOTE entry inside the compiled.elf. The File Explorer and Desktop use this to display the correct icon. Seeelf_metadata.mdfor full details.
Running It
If you build the project, you can open the Terminal and type:
/ # hello_world
Hello, World from BoredOS Userland!
Did you know my favorite number is 67?
/ #