uh_halp
uh_halp.vars
Gets template variables that can be inserted into the context.
get_os
Returns a string describing the OS.
get_shell
Returns the user's shell executable name.
apply_vars
Replaces strings in a json-style object tree. Use {var}
get_vars
Gets variables that can be replaced with templates. To use one, reference it like {var} in any string field.
Current keys are:
- shell: The user's shell executable name.
- os: A string describing the OS and its version.
- query: The query string.
- pwd: The current working directory.
- key: the secret key for the service (blank here, requested interactively if needed)
uh_halp.config
reset_config
Resets the config file to the template
save_config
Saves the config file
get_config
Reads the config file, creating it from template if it doesn't exist
uh_halp.backend.web_api
Generic web API functions
query
def query(endpoint: str, method: str, query: str, post_data: str,
headers: dict[str, str], response_path: list[str | int]) -> str
Standard web API request.
extract
If there's a response_path list, treat the response as JSON and the list as the path to the key we want. Use strings for property names, ints for list indices, and you can use negative indices to reference the end of a list (i.e. -1 for the last item.)
uh_halp.backend.openai
For calling the OpenAI completion model.
query
Calls the OpenAI API with the query from the command line.
uh_halp.backend
uh_halp.backend.util
clean
Cleans the response from the API, because we can't trust it to play nicely.
uh_halp.__main__
uh_halp.keys
prompt_key
Prompt the user for a key for the given service, returning it as a string
load_keys
Load the keys from disk and return them
save_keys
Save all the keys to disk
save_key
Save the service's key to disk
load_key
Load the key from disk, returning it.
get_key
Loads the service's key from ~/.uh-keys, or prompts for it and saves it there.
uh_halp.main
Contains main entrypoint
show_help
uh command line help on the command line
Usage: uh [query]
Example:
user@host$ uh get the time date +%H:%M:%S
config is in ~/.uh_config. Each field is parsed with mustache. Access tokens go in ~/.uh-keys
get_func
Returns a function in the given module name.
main
Entrypoint for the CLI.