Last active
January 29, 2022 05:09
-
-
Save himanoa/1b6ed1f920687224c1a3f308d99b14ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from argparse import ArgumentParser | |
import os | |
import subprocess | |
def run(): | |
usage = 'Usage: pretty-output <command_name> [...argv]' | |
argparser = ArgumentParser(usage=usage) | |
argparser.add_argument('command_name', help='Execute command', nargs="*") | |
command = " ".join(argparser.parse_args().command_name) | |
result = subprocess.run(command, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell=True) | |
msg = """\ | |
```bash | |
$ {0} | |
{1}```""".format(command, result.stdout.decode("utf8")) | |
print(msg) | |
if __name__ == '__main__': | |
run() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use