aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2023-11-27 21:01:27 +0100
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2023-11-27 21:01:27 +0100
commit4aa8834d392d65da1eb55b5c600bf8d4030d0e80 (patch)
treec2a0d16cff3d869f3e3f4eb3081dc1d9404fbdd5
parentf79efd43e44ae74bfae098d49bf9c5b2876eda5d (diff)
Add os.args to demo.
-rw-r--r--build.bat2
-rwxr-xr-xbuild_odin.sh2
-rw-r--r--examples/demo/demo.odin8
3 files changed, 9 insertions, 3 deletions
diff --git a/build.bat b/build.bat
index 41e32f5ed..050789bbc 100644
--- a/build.bat
+++ b/build.bat
@@ -111,7 +111,7 @@ call build_vendor.bat
if %errorlevel% neq 0 goto end_of_build
rem If the demo doesn't run for you and your CPU is more than a decade old, try -microarch:native
-if %release_mode% EQU 0 odin run examples/demo
+if %release_mode% EQU 0 odin run examples/demo -- Hellope World
del *.obj > NUL 2> NUL
diff --git a/build_odin.sh b/build_odin.sh
index f9747b52c..589aeb550 100755
--- a/build_odin.sh
+++ b/build_odin.sh
@@ -119,7 +119,7 @@ build_odin() {
}
run_demo() {
- ./odin run examples/demo/demo.odin -file
+ ./odin run examples/demo/demo.odin -file -- Hellope World
}
if [ $# -eq 0 ]; then
diff --git a/examples/demo/demo.odin b/examples/demo/demo.odin
index 00dd8a171..417011281 100644
--- a/examples/demo/demo.odin
+++ b/examples/demo/demo.odin
@@ -44,7 +44,13 @@ the_basics :: proc() {
fmt.println("\n# the basics")
{ // The Basics
- fmt.println("Hellope")
+
+ // os.args holds the path to the current executable and any arguments passed to it.
+ if len(os.args) == 1 {
+ fmt.printf("Hellope from %v.\n", os.args[0])
+ } else {
+ fmt.printf("%v, %v! from %v.\n", os.args[1], os.args[2], os.args[0])
+ }
// Lexical elements and literals
// A comment