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

Refactor CLI to use Cobra #52

Merged
merged 8 commits into from
Mar 26, 2024
Merged

Refactor CLI to use Cobra #52

merged 8 commits into from
Mar 26, 2024

Conversation

calvinmclean
Copy link
Owner

@calvinmclean calvinmclean commented Mar 11, 2024

Refactoring the API to use Cobra which will make it easier to add better subcommand structure and flags. It will also make the CLI more extendable.

Remaining TODOs (or create separate issue to track):

  • Combine address and bindAddress to use the same var and flag name, but they will have separate defaults and descriptions since they are part of different subcommands
  • Add API modifier method to add custom subcommands to a CLI (Allow adding custom subcommands #53)
  • Add subcommand and flags for a "raw request" that doesn't require interacting with a Resource (Add subcommand and flags for a "raw request" that doesn't require interacting with a Resource #54)
  • Change request body to be a flag for Post, Put, and Patch instead of positional argument
  • Add flag to read request body from file just use cat I think...
  • Change parent IDs to be a flag instead of positional and add validation to CLI for better documentation (also look into creating custom flags depending on Client parents names)
  • Use strings.ToLower() for client names as subcommands ("todos" instead of "TODOs" on CLI). Or use cobra.EnableCaseInsensitive
  • CommandLineTest is not very useful since it doesn't parse the actual args and still requires setting body, query, etc.

Copy link

codecov bot commented Mar 11, 2024

Codecov Report

Merging #52 (7a84596) into main (f025139) will decrease coverage by 0.67%.
The diff coverage is 88.73%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #52      +/-   ##
==========================================
- Coverage   81.00%   80.33%   -0.67%     
==========================================
  Files          23       23              
  Lines        1179     1246      +67     
==========================================
+ Hits          955     1001      +46     
- Misses        150      162      +12     
- Partials       74       83       +9     

@calvinmclean calvinmclean force-pushed the feature/cobra-cli branch 2 times, most recently from f442558 to b2bb680 Compare March 26, 2024 05:27
@calvinmclean calvinmclean merged commit 5698b65 into main Mar 26, 2024
5 checks passed
@calvinmclean calvinmclean deleted the feature/cobra-cli branch March 26, 2024 05:58
@calvinmclean calvinmclean restored the feature/cobra-cli branch March 31, 2024 21:18
@calvinmclean calvinmclean deleted the feature/cobra-cli branch March 31, 2024 21:19
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.

None yet

1 participant