7||| Get the command-line arguments that the program was called with.
8getArgs : IO (List String)
9getArgs = do n <- numArgs
13 numArgs = foreign FFI_C "idris_numArgs" (IO Int)
15 getArg : Int -> IO String
16 getArg x = foreign FFI_C "idris_getArg" (Int -> IO String) 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' = foreign FFI_C "getenv" (String -> IO String) 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 <- foreign FFI_C "setenv" (String -> String -> Int -> IO Int) 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 <- foreign FFI_C "unsetenv" (String -> IO Int) key
50getEnvironment : IO (List (String, String))
51getEnvironment = getAllPairs 0 []
53 getEnvPair : Int -> IO String
54 getEnvPair i = foreign FFI_C "getEnvPair" (Int -> IO String) 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)
71||| Quit with a particular exit code
73exit code = foreign FFI_C "exit" (Int -> IO ()) code
77time = foreign FFI_C "idris_time" (IO Int)
80usleep i = foreign FFI_C "usleep" (Int -> IO ()) i
82system : String -> IO Int
83system 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