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

REPL inspection outputs in CLI for Continuous Integration #189

Closed
marcellodesales opened this issue Sep 15, 2019 · 10 comments
Closed

REPL inspection outputs in CLI for Continuous Integration #189

marcellodesales opened this issue Sep 15, 2019 · 10 comments

Comments

@marcellodesales
Copy link

Is it possible to use Evans to output the properties of a given Proto? I just want to use Evans to instrospect Protos for Rapid development and I'd like to show the output of Evans in a CI job... I need to show the following:

  • Packages
  • For the development package, show
    • service
    • show prc
    • describe messages...

The flow of what I'm looking for is in the REPL, but an as CI is automated, I need to get the same outputs like the ones below...

thank you

evans --path proto_modules/validation v1/users.proto

  ______
 |  ____|
 | |__    __   __   __ _   _ __    ___
 |  __|   \ \ / /  / _. | | '_ \  / __|
 | |____   \ V /  | (_| | | | | | \__ \
 |______|   \_/    \__,_| |_| |_| |___/

 more expressive universal gRPC client


127.0.0.1:50051> show package
+----------+
| PACKAGE  |
+----------+
| users.v1 |
| validate |
+----------+

127.0.0.1:50051> package users.v1

users.v1@127.0.0.1:50051> show service
+---------+----------+--------------+------------------+
| SERVICE |   RPC    | REQUEST TYPE |  RESPONSE TYPE   |
+---------+----------+--------------+------------------+
| Users   | Register | NewUser      | RegisterResponse |
+---------+----------+--------------+------------------+

users.v1@127.0.0.1:50051> desc NewUser
+-----------+-------------+----------+
|   FIELD   |    TYPE     | REPEATED |
+-----------+-------------+----------+
| email     | TYPE_STRING | false    |
| password  | TYPE_STRING | false    |
| user_name | TYPE_STRING | false    |
+-----------+-------------+----------+

users.v1@127.0.0.1:50051> show rpc
+----------+--------------+------------------+
|   RPC    | REQUEST TYPE |  RESPONSE TYPE   |
+----------+--------------+------------------+
| Register | NewUser      | RegisterResponse |
+----------+--------------+------------------+

users.v1@127.0.0.1:50051> desc RegisterResponse
+-------+-------------+----------+
| FIELD |    TYPE     | REPEATED |
+-------+-------------+----------+
| id    | TYPE_STRING | false    |
| token | TYPE_STRING | false    |
+-------+-------------+----------+```
@ktr0731
Copy link
Owner

ktr0731 commented Sep 16, 2019

Currently, Evans doesn't support such feature... (I'm going to plan to implement it in the nearly future, but not now)
I think you can achieve such operation by using gRPCurl.

Thanks.

@marcellodesales
Copy link
Author

@ktr0731 thank you! Appreciated your reply... let me know when you guys do it!

@ktr0731
Copy link
Owner

ktr0731 commented Sep 18, 2019

I don't have much time to develop Evans, so I can't say when I can do it...
If you are familiar with Go and it is possible, it is helpful for me to send PRs ;)

@marcellodesales
Copy link
Author

@ktr0731 Sounds good... I just need the same output of the CLI taking a proto, so it shouldn't be too far from what you already have...

@marcellodesales
Copy link
Author

I will try working on it during hacktoberfest.

@marcellodesales
Copy link
Author

@ktr0731 Here's the design I wanna use:

Show Packages

evans --mode cli --path proto_modules/validation v1/users.proto --show-packages
+----------+
| PACKAGE  |
+----------+
| users.v1 |
| validate |
+----------+

Show Services

  • Shows the list of services or a specific service
evans --mode cli --path proto_modules/validation v1/users.proto --package users.v1 --service 
+---------+----------+--------------+------------------+
| SERVICE |   RPC    | REQUEST TYPE |  RESPONSE TYPE   |
+---------+----------+--------------+------------------+
| Users   | Register | NewUser      | RegisterResponse |
+---------+----------+--------------+------------------+

Describe Messages

  • List or describe messages
evans --mode cli --path proto_modules/validation v1/users.proto --package users.v1 --service Users  --desc NewUser
+-----------+-------------+----------+
|   FIELD   |    TYPE     | REPEATED |
+-----------+-------------+----------+
| email     | TYPE_STRING | false    |
| password  | TYPE_STRING | false    |
| user_name | TYPE_STRING | false    |
+-----------+-------------+----------+

@ktr0731
Copy link
Owner

ktr0731 commented Oct 5, 2019

Looks good 👍
However, I thought it is better to use a string flag, such that --show package or --show service because I'm planning to change the Evans CLI according to #190. This form is similar to sub-commands.

In addition, I think that it is better to format output with JSON in almost cases because we can combine other tools such like jq. Maybe it can be done by using present/json in Evans.
If you think that Evans should also support table format in CLI mode, let's support it 😄 (Maybe we need to add a flag that specifies the format type. For example, --format json or --format table.)

Example JSON output:

{
  "packages": [
    {
      "package": "api"
    }
  ]
}
{
  "services": [
    {
      "service": "Example",
      "rpc": "Unary",
      "request type": "SimpleRequest",
      "response type": "SimpleResponse"
    },
    {
      "service": "Example",
      "rpc": "UnaryMessage",
      "request type": "UnaryMessageRequest",
      "response type": "SimpleResponse"
    },
    {
      "service": "Example",
      "rpc": "UnaryRepeated",
      "request type": "UnaryRepeatedRequest",
      "response type": "SimpleResponse"
    },
...

@marcellodesales
Copy link
Author

@ktr0731 That's awesome work on #209 ... Hope we can tackle this one soon!

@marcellodesales
Copy link
Author

Happy 2020!

@ktr0731
Copy link
Owner

ktr0731 commented May 3, 2020

This feature is now implemented in v0.9.0 🎉

@ktr0731 ktr0731 closed this as completed May 3, 2020
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

No branches or pull requests

2 participants