Cli Output #337
wrath-codes
started this conversation in
Ideas
Cli Output
#337
Replies: 1 comment 1 reply
-
Hi @wrath-codes! Yes, it should be possible to grab the output from these commands and reshape into something else. Currently, the output is raw text that you programatically can work with. Here's some quick experiments I just did to find and separate the output of the import subprocess
output = subprocess.run(["poetry", "poly", "diff"], capture_output=True)
# split by newline, and filter out any empty rows
rows = [str.split(row) for row in output.stdout.decode("utf-8").splitlines() if str.strip(row)]
# find the index of where the table/content begins
index= next((index for index, row in enumerate(rows) if row[0] == "brick"))
summary = rows[:index]
header = rows[index]
body = rows[index + 2:] The underlying Rich console that is used will crop long names by default. But this can be modified with: import os
my_env = os.environ.copy()
my_env["COLUMNS"] = "200" # or a bigger value
# pass the env to the subprocess.run command
output = subprocess.run(["poetry", "poly", "diff"], capture_output=True, env=my_env) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there any way of ouputting some cli commands(mainly diff, info and check) to a file or buffer or a dict? I wanted to build a vscode extension to run commands from the command palette. And maybe build a web view in vscode to visualize the blocks components and bases.
Beta Was this translation helpful? Give feedback.
All reactions