You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That's because alias is a type of a command now. For someone attempting to look at it, the way to query aliases now is to query commands, then check is_alias() defined by the Command trait. A lot of the implementation details in the code referring to aliases, like find_alias(), refer to the old alias implementation and will be removed eventually.
Is @kubouch's change in question part of this PR: #8557
It would be my first contribution to nushell so I'm in the process of setting up my dev environment and can start exploring the code now! I've gone through the Review Process section of CONTRIBUTING.md but please let me know if I'm missing a step wrt assigning this to myself.
@AyushSingh13 Great, it's yours! You can just start exploring and even if you're not ready and have some questions you can open a draft PR, it's easier to discuss over code.
thank you - will create a new issue/ask on Discord! I have hidden the comment so it doesn't pollute this thread and will come back with specifics about this issue ASAP
@jooooscha - I think that's a great idea - I have started to explore the code so will report back on what changes are required for this :)
PS: for anyone that's interested, I fixed my tmux issue on both laptops by doing a tmux kill-server. I'm still not sure what the root cause was but the server seemed to have gone into some bad state and I haven't been able to reproduce it/link it explicitly back to nushell.
Either way, will continue on with this issue finally! Apologies for the delay!
Update: I've spent some time exploring the code and I'm being a Rust ecosystem + language newbie at the same time so thank you for bearing with me.
I understand that crates/nu-command/src/system/which_.rs has a which_single function which eventually leads down to a get_entry_in_commands function which is responsible for returning Nushell built-in command/Nushell custom command.
For some reason the call to check if something is a custom_command (engine_state.get_decl(decl_id).is_custom_command()) returns false. I also checked that engine_state.aliases is an empty vector even though I have defined alias ll = ls -al as my test alias.
So far I'm doing some newbie println! debugging but going to try and understand LLDB to see if I can do some more sophisticated debugging to understand the code path for adding an alias and then fetching an existing alias a bit better. Any advice on levelling up on the Rust side quicker is appreciated ofc :)
engine_state.aliases is still the old alias implementation that will be deleted. Actually, most of the stuff referring to aliases in the engine is the old implementation and will be deleted. The current aliases are implemented as decls, but they should return true when you call is_alias() on them.
Inside which_.rs there is get_entry_in_aliases() which again refers to the old alias implementation and will be deleted. The correct way to query aliases would probably be to use the get_entry_in_commands() and then add another if-else branch there checking for is_alias().
Thank you for your guidance and apologies for completely dropping the ball on this for so long! I have created this super simple draft PR here: #9580 (review)
Just checking how the tests work and will hopefully be ready for review soon - thank you again for your patience!
Once this is done, I can an issue for implementing @jooooscha's idea of displaying alias definitions in which too.
Activity
kubouch commentedon Mar 23, 2023
That's because alias is a type of a command now. For someone attempting to look at it, the way to query aliases now is to query commands, then check
is_alias()defined by the Command trait. A lot of the implementation details in the code referring to aliases, likefind_alias(), refer to the old alias implementation and will be removed eventually.a13h commentedon Mar 23, 2023
I am happy to try working on this!
Is @kubouch's change in question part of this PR: #8557
It would be my first contribution to nushell so I'm in the process of setting up my dev environment and can start exploring the code now! I've gone through the Review Process section of CONTRIBUTING.md but please let me know if I'm missing a step wrt assigning this to myself.
kubouch commentedon Mar 23, 2023
@AyushSingh13 Great, it's yours! You can just start exploring and even if you're not ready and have some questions you can open a draft PR, it's easier to discuss over code.
a13h commentedon Mar 24, 2023
@kubouch - awesome, thank you! Will come back with loads of questions this weekend I'm sure :)
a13h commentedon Mar 28, 2023
rgwood commentedon Mar 28, 2023
^that doesn't seem related to this issue. You will likely have better luck filing a new issue or asking on Discord.
a13h commentedon Mar 28, 2023
thank you - will create a new issue/ask on Discord! I have hidden the comment so it doesn't pollute this thread and will come back with specifics about this issue ASAP
jooooscha commentedon Mar 29, 2023
Just to add my three cents: The
whichcommand in bash shows the definition of the alias. This is useful when you forget what exactly the alias does.For example, for
alias hi=echo "hi", callingwhich hiwould reveal the definitionecho "hi".I think this is an important feature, and the nushell
whichcommand should show that, too.a13h commentedon Mar 31, 2023
@jooooscha - I think that's a great idea - I have started to explore the code so will report back on what changes are required for this :)
PS: for anyone that's interested, I fixed my
tmuxissue on both laptops by doing atmux kill-server. I'm still not sure what the root cause was but the server seemed to have gone into some bad state and I haven't been able to reproduce it/link it explicitly back tonushell.Either way, will continue on with this issue finally! Apologies for the delay!
a13h commentedon Apr 6, 2023
Update: I've spent some time exploring the code and I'm being a Rust ecosystem + language newbie at the same time so thank you for bearing with me.
I understand that
crates/nu-command/src/system/which_.rshas awhich_singlefunction which eventually leads down to aget_entry_in_commandsfunction which is responsible for returningNushell built-in command/Nushell custom command.For some reason the call to check if something is a custom_command (
engine_state.get_decl(decl_id).is_custom_command()) returnsfalse. I also checked thatengine_state.aliasesis an empty vector even though I have definedalias ll = ls -alas my test alias.So far I'm doing some newbie
println!debugging but going to try and understand LLDB to see if I can do some more sophisticated debugging to understand the code path for adding an alias and then fetching an existing alias a bit better. Any advice on levelling up on the Rust side quicker is appreciated ofc :)kubouch commentedon Apr 6, 2023
engine_state.aliasesis still the old alias implementation that will be deleted. Actually, most of the stuff referring to aliases in the engine is the old implementation and will be deleted. The current aliases are implemented as decls, but they should returntruewhen you callis_alias()on them.Inside
which_.rsthere isget_entry_in_aliases()which again refers to the old alias implementation and will be deleted. The correct way to query aliases would probably be to use theget_entry_in_commands()and then add another if-else branch there checking foris_alias().a13h commentedon Jul 1, 2023
Thank you for your guidance and apologies for completely dropping the ball on this for so long! I have created this super simple draft PR here: #9580 (review)
Just checking how the tests work and will hopefully be ready for review soon - thank you again for your patience!
Once this is done, I can an issue for implementing @jooooscha's idea of displaying alias definitions in
whichtoo.fixes `which` showing aliases as built-in nushell commands (#9580)