-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #135 from ollien/check-if-wrapped
- Loading branch information
Showing
3 changed files
with
29 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,28 @@ | ||
defmodule Burrito.Util.Args do | ||
@moduledoc """ | ||
This module provides a method to help fetch CLI arguments passed down | ||
from the Zig wrapper binary. | ||
This module provides a method to help fetch CLI arguments, whether passed down | ||
from the Zig wrapper binary or from the the system. | ||
""" | ||
|
||
@doc """ | ||
Get CLI arguments passed down from the Zig wrapper binary. Do note that this will get OTP | ||
runtime arguments when called outside of a Burrito-built context. You may consider | ||
`argv/0` as a more general alternative. | ||
""" | ||
@spec get_arguments :: list(String.t()) | ||
def get_arguments do | ||
:init.get_plain_arguments() |> Enum.map(&to_string/1) | ||
end | ||
|
||
@doc """ | ||
Get the arguments from the CLI, regardless if run under Burrito or not. | ||
""" | ||
@spec argv :: list(String.t()) | ||
def argv do | ||
if Burrito.Util.running_standalone?() do | ||
get_arguments() | ||
else | ||
System.argv() | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters