Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Write a meaningful CLI using the client library #52

Open
pohlm01 opened this issue Oct 29, 2024 · 8 comments
Open

Write a meaningful CLI using the client library #52

pohlm01 opened this issue Oct 29, 2024 · 8 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@pohlm01
Copy link
Member

pohlm01 commented Oct 29, 2024

The intention is to create a CLI application that uses the openleadr-client crate to allow users to create/update/modify/delete programs/events/reports/vens/resources on the VTN.

The file openleadr-client/src/bin/cli.rs contains a stub for a CLI application, which needs to be filled.

@pohlm01 pohlm01 converted this from a draft issue Oct 29, 2024
@pohlm01 pohlm01 added enhancement New feature or request help wanted Extra attention is needed labels Oct 29, 2024
@KeeganMyers
Copy link
Contributor

I can pick this up. I will probably use clap crate unless you have strong feelings otherwise.

@pohlm01
Copy link
Member Author

pohlm01 commented Oct 31, 2024

Sounds good to me

@pohlm01 pohlm01 assigned pohlm01 and KeeganMyers and unassigned pohlm01 Oct 31, 2024
@KeeganMyers
Copy link
Contributor

#60 covers this issue

@KeeganMyers
Copy link
Contributor

Based on your comments in the closed PR I'm looking through types like VenClient the need to pass self is an issue for CLI interaction since constructing that type requires a Ven . What would more closely match your design pattern, remove &self and replace it with applicable params to identify the ven, or create a new type similar to VenClient for Cli interop?

@KeeganMyers
Copy link
Contributor

For reference sake I'm using clap with derive sub commands to mimic the structure of k8s or docker commands i.e

./cli ven ls
./cli ven get id=11232

If we removed self from VenClient we could then call mutations with

./cli ven delete id=123

But at the moment the need to first create the struct makes that more difficult rather than just passing id directly to VenClient::delete

@pohlm01
Copy link
Member Author

pohlm01 commented Nov 12, 2024

Hm, that's a good one. We did not really consider that when designing the API of the client library.

Maybe there is a third option we could consider. If you want to delete a Event you first GET it and then DELETE it. This would effectively be one unnecessary request, but I don't think it harms a lot.
For most other modifying interactions besides DELETE, this pattern also seems helpful, if not necessary, to me. For example, when modifying an Event you probably want to set individual fields in the CLI, while the PUT request requires all fields to be present. Therefore, you would need to send a GET request before anyway.

./cli event update id=123 priority=5 # no need to provide all other event fields

Another example would be if you want to create a Report underneath an Event. According to the spec, you have to provide the ProgramID and EventID (which is a bit wired if you ask me). Instead of requiring the ProgramID as CLI argument, we would GET the Event and use the ProgramID stored in there.

What do you think of this approach?

@pohlm01
Copy link
Member Author

pohlm01 commented Dec 3, 2024

Hey @KeeganMyers,
I was wondering whether there is anything I can still help you with. This issue is not a priority for us, so really take your time. I just wanted to make sure that you are still interested in this issue. Let me know if there is anything I can help you with!

@pohlm01
Copy link
Member Author

pohlm01 commented Jan 6, 2025

@KeeganMyers, I just removed you as an assignee from this issue as you seemed to be unresponsive the last months. If you are still interested, please send a short message and I'll assign you again. Let me know if you would like any help.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
Status: In Progress
Development

No branches or pull requests

2 participants