-
Notifications
You must be signed in to change notification settings - Fork 54
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
feature(install): automatically add alias on conflict command #11
feature(install): automatically add alias on conflict command #11
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @alvinmatias69
Thanks for taking your time.
I noticed a few things and I will slowly post feedback as I get the chance.
a1f859e
to
9894085
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alvinmatias69 thanks for your patience. I had a steep return to work.
I left a single note, but we need to take a diff direction UX-wise:
We need to collect the information about aliases on the selected shells before hand, and ask for approval and the chosen name before hand, before installing g and whatsoever.
Also, in case there are more than one selected shell with an alias conflict, we prompt once and use the same confirmation and alias to configure all the selected shells.
This is probably a very edge case (an user with two diff shells, having both the g alias), but it is also very odd to have the user type, let's say ggovm
in one shell and g
in other.
So to summarize:
- We collect info about conflicting aliases in any of the selected shells, before hand
- Before proceeding with the installation/upgrade, we prompt for confirmation to setup alternative name for
g
(confirmation, then choose the name) - We configure the alias in every shell selected for installation, no matter if some of the selected shells don't need it
PD: I pushed some stuff I had lingering around to the next
branch. You would ideally rebase your branch on top of it.
Let me know if you have any questions.
Hey @alvinmatias69 , were you able to make some progress here? If you need advise or have doubts, don't hesitate to ping me. If in other hand, it gets too complicated or you don't have the time to keep working on it, I can put some time later this week and take it from here. Let me know! |
hey, I'm sorry for the long wait. It's been hectic at work lately. I've been working on it tho, but I still need some time to finish this. I'm truly sorry |
No worries @alvinmatias69, since you have work in progress, take your time to finish up. Let me know if you have doubts. <3 |
94e7228
to
e98ed14
Compare
Hi @stefanmaric, I've made some changes regarding our discussion above. The install scripts will check every selected shell to makes sure that there's no alias conflict. And, every shell will have the same alias. Will you please kindly recheck it? |
Giving it a look now.
Thank you for your help! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alvinmatias69 I left a pair of comments, but overall looks good. 👍
# | ||
|
||
exists() { | ||
case "$1" in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alvinmatias69 here you gotta add a default case. It will say "g alias does exist" in the shells not supported by the alias setup feature.
For non-supported shells, we can simply assume g doesn't exists, and skip the whole thing since we cannot do anything anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we skip the alias configuration for all shells or only those shells are not supported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really following.
So the deal here is that, as it stands now, if you try to install g in a shell diff from the ones here (zsh, bash, fish), for example, in ash, you will be promoted to setup an alias in ash, even tho we don't support it (yet, hopefully). And you will also be stuck in a loop of prompts.
This because exit code 0 means "does exist" while exit code 1 means "does not exist".
Since there's no defuault case, when the shell is not supported the default exit code is 0.
So an *) return 1;;
at the end would help fix these cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should invert the exit codes and add explicit returns inside if statements to make it clearer for future readers. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or am I missing something? I'm reviewing from my phone so I don't have the big picture. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I get it. I initially thought that the alias won't be set for all shells if there's an unsupported shell. So, basically return 1
as default so the installer won't recognize it as already exists alias, right? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That. I think we are on the same page now. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allrite, I'm already on it
bin/install
Outdated
|
||
set_g_alias() { | ||
if [ "$G_ALIAS_CHANGED" = true ]; then | ||
log_info "info" "configuring $G_ALIAS as alias in $1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this log since it would output "configuring X in file Y" twice for each shell. Since the setup of env vars and the setup of the aliases affect the same files, let's treat them as the same operation.
e98ed14
to
0a79522
Compare
On some shell (especially zsh), `g` is already used or aliased for other command. Prompt user to enter new alias for `g` on installation. fix [stefanmaric#10](stefanmaric#10)
0a79522
to
e0e2fa4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alvinmatias69 ready to merge now. Thanks again for your contribution! ❤️
Thanks man, really glad to contribute. I'm gonna watch some issues for future improvement 🔥 |
- Warn users about existing go installations - Improve self-upgrade script - Improve previous installation detection on g-install - Make self-upgrade throw if g was not installed via g-install - Add alias collision detection and setup helper (#11, thanks @alvinmatias69) - Add `download` and `set` commands (#12, thanks @feualpha) * BREAKING: Remove the `--download` option - Add Makefile with lint and format targets for better DX - Fix shellcheck lint errors - Format source code using make format - Improve and update docs to reflect latest contributions
On some shell (especially zsh),
g
is already used or aliased for othercommand. Prompt user to enter new alias for
g
on installation.fix #10