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

Support Flags for positional arguments and request bodies #236

Open
thebauda opened this issue Jan 12, 2024 · 3 comments
Open

Support Flags for positional arguments and request bodies #236

thebauda opened this issue Jan 12, 2024 · 3 comments

Comments

@thebauda
Copy link

TLDR; Support accessing positional arguments and request bodies as flags

When a restish command is available that was generated from an endpoint that path parameters and/or takes a request body, the command is structured as so:

restish <api> <command> <positional-argument-1> '{input.json}'

For example, the following endpoint with the following request body
POST my-api/v2/orgs/{org_id}/create_user_in_organization

{
  "first_name": string,
  "last_name": string
}

would be called by restish as so

restish my-api create-user-in-organization <org-id> '{"first_name": "foo","last_name": "bah"}'

It would be better if restish could support using flags to pass values to positional arguments and request bodies. The above example could then be called as so:

restish my-api create-user-in-organization --org-id <org-id> --first-name "foo" last-name "bah"
@danielgtaylor
Copy link
Owner

danielgtaylor commented Jan 19, 2024

@thebauda why would this be better? Flags are typically optional while the org-id positional parameter is always required in your example. You can also use the CLI shorthand for the body to save yourself having to type out JSON like this:

restish my-api create-user-in-organization MyOrg first_name: foo, last_name: bah

@thebauda
Copy link
Author

@thebauda why would this be better? Flags are typically optional while the org-id positional parameter is always required in your example. You can also use the CLI shorthand for the body to save yourself having to type out JSON like this:

restish my-api create-user-in-organization MyOrg first_name: foo, last_name: bah

I'd like it where required and non-required items can be passed as flags. Not all of my users are familiar with CLI shorthand, and as you stated, writing JSON can be cumbersome and error-prone.

@thebauda
Copy link
Author

Would you ever be willing to give my team and I a walkthrough on the Restish project architecture? I'd like to contribute PRs that introduce new features and have you review them.

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