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

Feature Request: command-line option to output to a file #410

Closed
ikirker opened this issue Aug 25, 2021 · 3 comments
Closed

Feature Request: command-line option to output to a file #410

ikirker opened this issue Aug 25, 2021 · 3 comments
Milestone

Comments

@ikirker
Copy link

ikirker commented Aug 25, 2021

Problem

A number of times we've wanted to get output from the module command and redirect it, or pipe it into another command. It's always a bit of a hassle and can be surprisingly tricky to get right in some circumstances, because of the various things module and modulecmd do to get the output to the user.

Proposed solution

An explicit command-line option that directs to a file all output that would normally be presented to the user.

E.g.:

$ module whatis strace
---- /shared/ucl/apps/modulefiles/development ----
         strace/4.12: Adds strace 4.12 to your environment. Trace system calls and signals.
$ module whatis --output-file=module.whatis.strace strace
$ cat module.whatis.strace
---- /shared/ucl/apps/modulefiles/development ----
         strace/4.12: Adds strace 4.12 to your environment. Trace system calls and signals.

Does this seem feasible and sensible?

@xdelaruelle
Copy link
Member

I will look if I can add an option to control whether or not the output should be redirected to stdout. With that you should be assured to find the output on either stdout or stderr to then pipe or redirect the chosen channel.

$ module whatis --redirect strace | grep string-i-search
$ module avail -t --do-not-redirect 2>avail-in-a-file

If such option cannot be implemented, I will go for a specific option to redirect output to a file like the --output-file option in your example.

@xdelaruelle xdelaruelle added this to the 5.1 milestone Aug 30, 2021
@xdelaruelle
Copy link
Member

Work is almost finished on this feature, so I can confirm it will be part of version v5.1.

A redirect_output configuration option is added to set by default if output should be redirected or not. Also the --redirect and --no-redirect command-line switches are added to change behavior for a specific command run.

@ikirker
Copy link
Author

ikirker commented Oct 18, 2021

@xdelaruelle Thank you for implementing this, I'll look forward to the release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants