Exampling Loading Functions
list_examples
MacroEnergy.list_examples — Function
list_examples(; auth::Any)::Vector{String}List all available examples in the MacroEnergyExamples repository. This function will print the names of all examples and return a vector of their names. These names can be used with download_example and other methods to download or get information about specific examples.
The auth parameter can be used to authenticate your requests to the GitHub API. It should be a valid GitHub.OAuth2 object created using the authenticate_github method, or a GitHub.UsernamePassAuth or GitHub.JWTAuth object created using the GitHub.jl package.
download_example
MacroEnergy.download_example — Function
download_example(example_name::String, target_dir::String = pwd(); auth::Any)::NothingDownload an example from the MacroEnergyExamples repository to a specified target directory. The example_name should match one of the names listed by list_examples(). The target_dir is the directory where the example will be downloaded, defaulting to the current working directory.
The auth parameter can be used to authenticate your requests to the GitHub API. It should be a valid GitHub.OAuth2 object created using the authenticate_github method, or a GitHub.UsernamePassAuth or GitHub.JWTAuth object created using the GitHub.jl package.
download_examples
MacroEnergy.download_examples — Function
download_examples(target_dir::String = pwd(), pause_seconds::Float64 = 1.0; auth::Any)::NothingDownload all examples from the MacroEnergyExamples repository to a specified target directory.
The target_dir is the directory where all examples will be downloaded, defaulting to the current working directory. pause_seconds is the time to pause between downloads to avoid hitting GitHub API rate limits.
The auth parameter can be used to authenticate your requests to the GitHub API. It should be a valid GitHub.OAuth2 object created using the authenticate_github method, or a GitHub.UsernamePassAuth or GitHub.JWTAuth object created using the GitHub.jl package.
example_readme
MacroEnergy.example_readme — Function
example_readme(example_name::String; auth::Any)::NothingDisplay the README.md file for a specific example from the MacroEnergyExamples repository. The example_name should match one of the names listed by list_examples().
The auth parameter can be used to authenticate your requests to the GitHub API. It should be a valid GitHub.OAuth2 object created using the authenticate_github method, or a GitHub.UsernamePassAuth or GitHub.JWTAuth object created using the GitHub.jl package.
example_contents
MacroEnergy.example_contents — Function
example_contents(example_name::String; auth::Any)::NothingDisplay the contents of a specific example from the MacroEnergyExamples repository. The example_name should match one of the names listed by list_examples(). This function will print the names of all files in the example directory.
The auth parameter can be used to authenticate your requests to the GitHub API. It should be a valid GitHub.OAuth2 object created using the authenticate_github method, or a GitHub.UsernamePassAuth or GitHub.JWTAuth object created using the GitHub.jl package.
find_example
MacroEnergy.find_example — Function
find_example(example_name::String; auth::Any)::Tuple{GitHub.Content, GitHub.Repo}Find an example by its name in the MacroEnergyExamples repository. These names can be obtained from list_examples(). find_example returns a tuple containing the GitHub.Content object for the requested examples GitHub directory and the GitHub.Repo object for the MacroEnergyExamples repository.
The auth parameter can be used to authenticate your requests to the GitHub API. It should be a valid GitHub.OAuth2 object created using the authenticate_github method, or a GitHub.UsernamePassAuth or GitHub.JWTAuth object created using the GitHub.jl package.
authenticate_github
MacroEnergy.authenticate_github — Function
authenticate_github(token::String)::GitHub.OAuth2Authenticate your downloads from GitHub using a personal access token. This function returns a GitHub.OAuth2 object that can be used for authenticated requests to the GitHub API.
You should create a personal access token in the GitHub settings under Developer settings -> Personal access tokens.
You can use the created OAuth2 token to authenticate your other function calls, for example:
auth = authenticate_github("your_personal_access_token")
list_examples(; auth=auth)
download_example("example_name"; auth=auth)sourcecheck_auth
MacroEnergy.check_auth — Function
check_auth(auth::Any)::NamedTupleCheck if the provided authentication object is valid for GitHub API requests. This function returns a NamedTuple containing the auth object if it is a valid type, or an empty NamedTuple otherwise.
The auth parameter can be a GitHub.OAuth2, GitHub.UsernamePassAuth, or GitHub.JWTAuth object.
download_gh
MacroEnergy.download_gh — Function
download_gh(dir_path::String, repo::GitHub.Repo, target_dir::String; auth::Any)::NothingDownload a directory from a GitHub repository to a specified target directory.
The dir_path is the path to the directory in the repository, repo is the GitHub.Repo object, and target_dir is the local directory where the contents will be downloaded.
download_gh(elem::GitHub.Content, repo::GitHub.Repo, target_dir::String; auth::Any)::NothingAttempt to download a single element (file or directory) from a GitHub repository to a specified target directory. If the element is a file, it will be downloaded directly. If it is a directory, the function will recursively download all contents within that directory.
The elem is a GitHub.Content object representing the file or directory, repo is the GitHub.Repo object, and target_dir is the local directory where the contents will be downloaded.