-
Couldn't load subscription status.
- Fork 36
Draft: Feature: Add support for generating json from bst show command #2030
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
Draft: Feature: Add support for generating json from bst show command #2030
Conversation
69494ab to
df01c09
Compare
This adds a new flag called --json to the `bst show` command which when specified will make bst output a machine readable JSON dump of the dependency state within the current buildstream project. Having JSON support makes it easier to write tools that need to inspect the configuration of a buildstream enabled project.
df01c09 to
524c1a4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I like this. It's more easily parsed, and doesn't suffer from the pitfalls of trying to format yaml using the current --format option.
I think adding yaml output with the same semantics would be good, especially as buildstream is already yaml-centric.
The implementation itself uses names that are already taken, but that shouldn't be hard to fix.
| @click.option( | ||
| "--except", "except_", multiple=True, type=click.Path(readable=False), help="Except certain dependencies" | ||
| ) | ||
| @click.option("--json", "as_json", is_flag=True, help="Output the information as machine readable JSON") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have a similar option that outputs YAML, as that's what buildstream uses.
| ], | ||
| ), | ||
| help="The dependencies to show", | ||
| help="Types of Elements to Show", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep the old description. "Types of elements" doesn't make sense here.
| show_default=True, | ||
| multiple=True, | ||
| type=FastEnumType( | ||
| _ElementKind, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Element Kind" is definitely not how you should name this. The element kind is already a concept in buildstream, and it's not this.
I don't know what would be the best way to name this option though. info? keys?
Let's wait for other maintainer's opinions, they might have a better idea.
| raise AppError("--format and --json are mutually exclusive") | ||
|
|
||
| if format_ and kind: | ||
| raise AppError("--format does not support --kind") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I like this error message, as I see --format and --kind (in your current implementation) to be essentially the same thing except --format is used in the default mode and --kind is used in the json mode.
Maybe we could change it such that --format could take the special value json, and that would unlock the (replacement for the) --kind option.
Let's wait for other opinions.
|
Oh, I forgot. This also needs tests. You can probably just add a test or two to |
|
Closing this in favor of #2035 |
This adds a new flag called --json to the
bst showcommand which when specified will make bst output a machine readable JSON dump of the dependency state within the current buildstream project. Having JSON support makes it easier to write tools that need to inspect the configuration of a buildstream enabled project.