Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for aliases in ov #4407

Closed
sarayourfriend opened this issue May 30, 2024 · 1 comment · Fixed by #4409
Closed

Add support for aliases in ov #4407

sarayourfriend opened this issue May 30, 2024 · 1 comment · Fixed by #4409
Assignees
Labels
🤖 aspect: dx Concerns developers' experience with the codebase 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🟩 priority: low Low priority and doesn't need to be rushed 🧱 stack: mgmt Related to repo management and automations

Comments

@sarayourfriend
Copy link
Contributor

Problem

We tried adding aliases in #4343 using associative bash arrays. However, macOS's bash version is stuck on an older version that doesn't support associative arrays. So I removed that from the PR and decided to try it a different way in a future PR as a separate issue.

Description

Create some method of expanding aliases when running ov. For example, ov j should expand to ov just.

It should be possible with one-dimensional arrays, and treating odd-or-0 index as the alias and the following even index as the expansion. This would be preferred, as it's probably less overhead than something else (like the Python script).

Another option I thought of was to use Python to process argv in the entrypoint and expand the aliases there. The entrypoint could end with python ./docker/dev_env/expand_aliases.py "$@", and that script could import $OPENVERSE_PROJECT/.ov_aliases.py using a method like https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly, and then do something like:

#... import personal_aliases from $OPENVERSE_PROJECT/.ov_aliases.py

shared_aliases = {
    "j": "just",
}

all_aliases = shared_aliases | personal_aliases

args = sys.argv[1:]
if args[0] in all_aliases:
  args[0] = all_aliases[args[0]]

sys.execv(args)

Alternatives

@sarayourfriend sarayourfriend added 🟩 priority: low Low priority and doesn't need to be rushed 🤖 aspect: dx Concerns developers' experience with the codebase 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🧱 stack: mgmt Related to repo management and automations labels May 30, 2024
@sarayourfriend sarayourfriend self-assigned this May 30, 2024
@sarayourfriend
Copy link
Contributor Author

I've got the bash approach working pretty alright locally!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 aspect: dx Concerns developers' experience with the codebase 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🟩 priority: low Low priority and doesn't need to be rushed 🧱 stack: mgmt Related to repo management and automations
Projects
Archived in project
1 participant