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

Prefect CLI: Add a batch mode / plain output feature to the command line interface #6930

Open
3 tasks done
dcupp opened this issue Sep 22, 2022 · 2 comments
Open
3 tasks done
Labels
enhancement An improvement of an existing feature status:accepted We may work on this; we will accept work from external contributors

Comments

@dcupp
Copy link

dcupp commented Sep 22, 2022

First check

  • I added a descriptive title to this issue.
  • I used the GitHub search to find a similar request and didn't find it.
  • I searched the Prefect documentation for this feature.

Prefect Version

2.x

Describe the current behavior

The prefect command line interface outputs information in a way that makes it difficult to use with commands like grep, sed and awk.

If I run a command like prefect deployment ls, the command outputs two columns of information, but:

  1. the output has lots of non-whitespace characters that aren't data, being used for graphics (9473, 9523) -- this makes it more challenging to process
  2. there are header lines, and other extra lines (horizontal dividers) with no information -- lines like these are particularly awkward to deal with when piping commands
  3. the CLI command detects the width of my terminal, and if the lengths of the output rows exceed my terminal width, it truncates the data, and I don't get the output anyway.

Describe the proposed behavior

It would be great if there was an ENV var, or preferably a command line flag, that would turn off all of the fancy output, color codes, graphical characters, header/divider rows, and line truncation.

Example Use

I think a short flag would be best, like -b for batch mode or -q for quiet:

prefect deployment ls -b

Or an env var:

PLAIN_OUTPUT=1 prefect deployment ls

Additional context

I can provide an example use case: deleting deployments with a certain name, something like:

prefect deployment ls | grep "foo.*bar" | xargs -n 1 prefect deployment delete

There may be a better way to delete deployments that start and end with a certain string; I just made that up as an example.

@dcupp dcupp added enhancement An improvement of an existing feature status:triage labels Sep 22, 2022
@zanieb
Copy link
Contributor

zanieb commented Sep 22, 2022

We'd like to have a --json flag for all CLI commands which should cover this by outputting content in parsable JSON. I'd prefer the implementation be reusable across all of our CLI commands somehow. This will require some refactoring but I'm not opposed to a community contribution if it's done well.

@zanieb zanieb added status:accepted We may work on this; we will accept work from external contributors priority:low and removed status:triage labels Sep 22, 2022
@dcupp
Copy link
Author

dcupp commented Sep 22, 2022

A --json flag sounds like a great idea but doesn't really help my use case. I think filtering everything through jq first would be more onerous than writing my own CLI client.

[EDIT]
If you did that, maybe a more generic --output-format json|yaml|hocon|csv would be helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement of an existing feature status:accepted We may work on this; we will accept work from external contributors
Projects
None yet
Development

No branches or pull requests

3 participants