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

Now last executed CommandPipeline is available in __xonsh__.last #5422

Merged
merged 4 commits into from
May 22, 2024

Conversation

anki-code
Copy link
Member

@anki-code anki-code commented May 16, 2024

Motivation

There is no way to access to the CommandPipeline of executed command in uncaptured mode. This causes:

  • No chance to get return code in one universal way.
  • Barrier to trace and inspection.

Before

$(ls nofile)
# No way to access to the CommandPipeline of executed command.

After

$(ls nofile)
__xonsh__.last.rtn  # In interactive or not interactive.
# 2
# Sugar sir:
last = type('LastCP', (object,), {'__getattr__':lambda self, name: getattr(__xonsh__.last, name) })()

ls nofile
last.rtn
# 2

JFYI #5342

For community

⬇️ Please click the 👍 reaction instead of leaving a +1 or 👍 comment

Copy link
Collaborator

@gforsyth gforsyth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Having a consistent, programmatic place to grab this info seems like a good thing!

I'm going to merge this now, but we might also consider adding the execution time to this __xonsh__.last attribute.

Thanks @anki-code !

@gforsyth gforsyth merged commit aa69ce8 into main May 22, 2024
12 checks passed
@gforsyth gforsyth deleted the last_cp branch May 22, 2024 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants