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

CLI format flag #4777

Merged
merged 1 commit into from
Mar 25, 2022
Merged

CLI format flag #4777

merged 1 commit into from
Mar 25, 2022

Conversation

vytautas-karpavicius
Copy link
Contributor

@vytautas-karpavicius vytautas-karpavicius commented Mar 22, 2022

What changed?
Added CLI --format flag that allows consistent experience across all CLI commands to render different output.

  • table is default. As is currently used in most command as immediate output.
  • json is another option. Also deprecating --pjson flag used in couple of places (still works though).
  • text/template - this is useful option for selecting only one or few fields from the output. For example one could get all unique workflow types currently running like:
./cadence --do samples-domain workflow listall --open --format '{{.WorkflowType}}' | uniq
main.sampleSignalCounterWorkflow

Why?
This continues work towards presentation layer in CLI.

It adds a consistent way to render output in different format. Template mode is useful if command output for some specific purpose, scripting or piping output to other commands.

While it was already possible to output result as json and then use additional utilities such as sed or jq for formatting, it will much easier now.

It will also be more consistent. Planning to add this to all commands producing some output.

Finally, the same templating system can be used to render standard output of commands. For example, with this change I included describe domain output rendered as a default template (if none other is provided by user).

How did you test it?
Tested locally.

Potential risks

Release notes

Documentation Changes

@vytautas-karpavicius vytautas-karpavicius changed the title CLI --format flag CLI format flag Mar 23, 2022
@vytautas-karpavicius vytautas-karpavicius marked this pull request as ready for review March 23, 2022 13:22
@vytautas-karpavicius vytautas-karpavicius requested a review from a team March 23, 2022 13:22
@coveralls
Copy link

coveralls commented Mar 23, 2022

Pull Request Test Coverage Report for Build cfbe49db-7018-418b-a9e6-3364bf52449b

  • 200 of 254 (78.74%) changed or added relevant lines in 10 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.07%) to 56.947%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tools/cli/adminElasticSearchCommands.go 0 1 0.0%
tools/cli/taskListCommands.go 1 2 50.0%
tools/cli/adminTaskListCommands.go 0 2 0.0%
tools/cli/adminCommands.go 0 3 0.0%
tools/cli/workflowCommands.go 13 20 65.0%
tools/cli/render.go 151 168 89.88%
tools/cli/domainCommands.go 25 48 52.08%
Files with Coverage Reduction New Missed Lines %
common/task/weightedRoundRobinTaskScheduler.go 2 89.64%
Totals Coverage Status
Change from base Build 6334e043-04b6-4bf2-910b-6d6e60fadb7e: 0.07%
Covered Lines: 83576
Relevant Lines: 146761

💛 - Coveralls

@vytautas-karpavicius vytautas-karpavicius marked this pull request as draft March 23, 2022 14:06
@vytautas-karpavicius vytautas-karpavicius merged commit 950f5ac into master Mar 25, 2022
@vytautas-karpavicius vytautas-karpavicius deleted the cli-format-flag branch March 25, 2022 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants