8getArgs : IO (List String)
9getArgs = do n <- numArgs
13 numArgs = mkForeign (FFun "idris_numArgs" [] FInt)
15 getArg : Int -> IO String
16 getArg x = mkForeign (FFun "idris_getArg" [FInt] FString) x
18 ga' : List String -> Int -> Int -> IO (List String)
19 ga' acc i n = if (i == n) then (return $ reverse acc) else
21 ga' (arg :: acc) (i+1) n
23-- Retrieves an value from the environment, if the given key is present,
24-- otherwise it returns Nothing.
25getEnv : String -> IO (Maybe String)
28 is_nil <- nullStr str_ptr
31 else pure (Just str_ptr)
34 getEnv' = mkForeign (FFun "getenv" [FString] FString) key
36-- Sets an environment variable with a given value.
37-- Returns true if the operation was successful.
38setEnv : String -> String -> IO Bool
40 ok <- mkForeign (FFun "setenv" [FString, FString, FInt] FInt) key value 1
43-- Unsets an environment variable.
44-- Returns true if the variable was able to be unset.
45unsetEnv : String -> IO Bool
47 ok <- mkForeign (FFun "unsetenv" [FString] FInt) key
50getEnvironment : IO (List (String, String))
51getEnvironment = getAllPairs 0 []
53 getEnvPair : Int -> IO String
54 getEnvPair i = mkForeign (FFun "getEnvPair" [FInt] FString) i
56 splitEq : String -> (String, String)
58 -- FIXME: There has to be a better way to split this up
59 let (k, v) = break (== '=') str in
60 let (_, v') = break (/= '=') v in
63 getAllPairs : Int -> List String -> IO (List (String, String))
64 getAllPairs n acc = do
65 envPair <- getEnvPair n
66 is_nil <- nullStr envPair
68 then return $ reverse $ map splitEq acc
69 else getAllPairs (n + 1) (envPair :: acc)
72exit code = mkForeign (FFun "exit" [FInt] FUnit) code
75usleep i = mkForeign (FFun "usleep" [FInt] FUnit) i
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