9||| Retrieves a value from the environment if the given key is present,
10||| otherwise it returns Nothing.
11getEnv : String -> IO (Maybe String)
14 is_nil <- nullStr str_ptr
17 else pure (Just str_ptr)
20 getEnv' = foreign FFI_C "getenv" (String -> IO String) key
22||| Sets an environment variable with a given value.
23||| Returns true if the operation was successful.
24setEnv : String -> String -> IO Bool
26 ok <- foreign FFI_C "setenv" (String -> String -> Int -> IO Int) key value 1
29||| Unsets an environment variable.
30||| Returns true if the variable was able to be unset.
31unsetEnv : String -> IO Bool
33 ok <- foreign FFI_C "unsetenv" (String -> IO Int) key
36getEnvironment : IO (List (String, String))
37getEnvironment = getAllPairs 0 []
39 getEnvPair : Int -> IO String
40 getEnvPair i = foreign FFI_C "getEnvPair" (Int -> IO String) i
42 splitEq : String -> (String, String)
44 -- FIXME: There has to be a better way to split this up
45 let (k, v) = break (== '=') str in
46 let (_, v') = break (/= '=') v in
49 getAllPairs : Int -> List String -> IO (List (String, String))
50 getAllPairs n acc = do
51 envPair <- getEnvPair n
52 is_nil <- nullStr envPair
54 then pure $ reverse $ map splitEq acc
55 else getAllPairs (n + 1) (envPair :: acc)
57||| Quit with a particular exit code
59exit code = foreign FFI_C "exit" (Int -> IO ()) code
61||| Get the numbers of seconds since 1st January 1970, 00:00 UTC
63time = do MkRaw t <- foreign FFI_C "idris_time" (IO (Raw Integer))
66||| Specify interval to sleep for, must be in range [0, 1000000]
67usleep : (i : Int) -> { auto prf : So (i > 0 && i <= 1000000) } -> IO ()
68usleep i = foreign FFI_C "usleep" (Int -> IO ()) i
70system : String -> IO Int
71system cmd = foreign FFI_C "system" (String -> IO Int) cmd
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list