aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/world/program.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/world/program.lux')
-rw-r--r--stdlib/source/lux/world/program.lux42
1 files changed, 37 insertions, 5 deletions
diff --git a/stdlib/source/lux/world/program.lux b/stdlib/source/lux/world/program.lux
index acaf36711..d6fe4c2e3 100644
--- a/stdlib/source/lux/world/program.lux
+++ b/stdlib/source/lux/world/program.lux
@@ -14,6 +14,7 @@
[parser
["." environment (#+ Environment)]]]
[data
+ ["." bit ("#\." equivalence)]
["." maybe]
["." text
["%" format (#+ format)]]
@@ -216,7 +217,19 @@
(#static home [] #io Path))
(host.import: Kernel #as RubyKernel
- (#static exit [Int] #io Nothing)))}
+ (#static exit [Int] #io Nothing)))
+
+ @.php
+ (as_is (host.import: (exit [Int] #io Nothing))
+ ## https://www.php.net/manual/en/function.exit.php
+ (host.import: (getcwd [] #io host.String))
+ ## https://www.php.net/manual/en/function.getcwd.php
+ (host.import: (getenv #as getenv/1 [host.String] #io host.String))
+ (host.import: (getenv #as getenv/0 [] #io (Array host.String)))
+ ## https://www.php.net/manual/en/function.getenv.php
+ ## https://www.php.net/manual/en/function.array-keys.php
+ (host.import: (array_keys [(Array host.String)] (Array host.String)))
+ )}
(as_is)))
(structure: #export default
@@ -254,7 +267,15 @@
(list\map (function (_ variable)
[variable (RubyEnv::fetch [variable])]))
(dictionary.from_list text.hash)
- io.io)}
+ io.io)
+ @.php (do io.monad
+ [environment (..getenv/0 [])]
+ (wrap (|> environment
+ ..array_keys
+ array.to_list
+ (list\map (function (_ variable)
+ [variable ("php array read" (:coerce Nat variable) environment)]))
+ (dictionary.from_list text.hash))))}
## TODO: Replace dummy implementation.
(io.io environment.empty))))
@@ -270,7 +291,12 @@
<default>)
@.python (os/path::expanduser ["~"])
@.lua (..run_command "~" "echo ~")
- @.ruby (RubyDir::home [])}
+ @.ruby (RubyDir::home [])
+ @.php (do io.monad
+ [output (..getenv/1 ["HOME"])]
+ (wrap (if (bit\= false (:coerce Bit output))
+ "~"
+ output)))}
## TODO: Replace dummy implementation.
<default>)))
@@ -294,7 +320,12 @@
(if (is? default on_windows)
(..run_command default "pwd")
(wrap on_windows)))
- @.ruby (RubyFileUtils::pwd [])}
+ @.ruby (RubyFileUtils::pwd [])
+ @.php (do io.monad
+ [output (..getcwd [])]
+ (wrap (if (bit\= false (:coerce Bit output))
+ "."
+ output)))}
## TODO: Replace dummy implementation.
(io.io <default>))))
@@ -314,4 +345,5 @@
(..default_exit! code))
@.python (os::_exit [code])
@.lua (os/exit [code])
- @.ruby (RubyKernel::exit [code])}))))
+ @.ruby (RubyKernel::exit [code])
+ @.php (..exit [code])}))))