9||| Get the command-line arguments that the program was called with.
10getArgs : IO (List String)
11getArgs = do n <- numArgs
15 numArgs = mkForeign (FFun "idris_numArgs" [] FInt)
17 getArg : Int -> IO String
18 getArg x = mkForeign (FFun "idris_getArg" [FInt] FString) x
20 ga' : List String -> Int -> Int -> IO (List String)
21 ga' acc i n = if (i == n) then (return $ reverse acc) else
23 ga' (arg :: acc) (i+1) n
25||| Retrieves an value from the environment, if the given key is present,
26||| otherwise it returns Nothing.
27getEnv : String -> IO (Maybe String)
30 is_nil <- nullStr str_ptr
33 else pure (Just str_ptr)
36 getEnv' = mkForeign (FFun "getenv" [FString] FString) key
38||| Sets an environment variable with a given value.
39||| Returns true if the operation was successful.
40setEnv : String -> String -> IO Bool
42 ok <- mkForeign (FFun "setenv" [FString, FString, FInt] FInt) key value 1
45||| Unsets an environment variable.
46||| Returns true if the variable was able to be unset.
47unsetEnv : String -> IO Bool
49 ok <- mkForeign (FFun "unsetenv" [FString] FInt) key
52getEnvironment : IO (List (String, String))
53getEnvironment = getAllPairs 0 []
55 getEnvPair : Int -> IO String
56 getEnvPair i = mkForeign (FFun "getEnvPair" [FInt] FString) i
58 splitEq : String -> (String, String)
60 -- FIXME: There has to be a better way to split this up
61 let (k, v) = break (== '=') str in
62 let (_, v') = break (/= '=') v in
65 getAllPairs : Int -> List String -> IO (List (String, String))
66 getAllPairs n acc = do
67 envPair <- getEnvPair n
68 is_nil <- nullStr envPair
70 then return $ reverse $ map splitEq acc
71 else getAllPairs (n + 1) (envPair :: acc)
73||| Quit with a particular exit code
75exit code = mkForeign (FFun "exit" [FInt] FUnit) code
79time = mkForeign (FFun "idris_time" [] FInt)
82usleep i = mkForeign (FFun "usleep" [FInt] FUnit) i
84system : String -> IO Int
85system cmd = mkForeign (FFun "system" [FString] FInt) 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