Adds explicit search command for better UX by scalvert · Pull Request #2 · gleanwork/glean-cli
Summary
⚠️ This PR got WAAAAAAAY out of control in terms of size, and I probably should have split it up, but 🤷♂️ .
Adds a glean search ... command to provide a better UX to perform searches. This command wraps our existing http client implementation and uses that to load config, perform search, etc. Most of the code relates to providing types for marshaling/unmarshaling.
This pull request includes significant refactoring and improvements to the command structure of the CLI. The changes focus on improving code maintainability by converting existing command functions to use a more consistent and modular approach.
Refactoring and Improvements:
-
Command Structure Refactoring:
cmd/api.go: RenamedapiOptionstoAPIOptions, updated function names to follow Go naming conventions, and removed theinitfunction in favor of returning the command fromNewCmdAPI. [1] [2] [3] [4]cmd/config.go: IntroducedConfigOptionsstruct, replacedvar configCmdwithNewCmdConfigfunction, and updated flag handling to use the new struct. [1] [2] [3] [4]cmd/generate.go: Replacedvar generateCmdwithNewCmdGeneratefunction.cmd/openapi_spec.go: IntroducedOpenAPISpecOptionsstruct, replacednewOpenapiSpecCmdwithNewCmdOpenAPISpecfunction, and updated flag handling to use the new struct. [1] [2] [3]
-
Test Updates:
cmd/api_test.go: Adjusted tests to use the newNewCmdAPIfunction and removed redundant test cases.cmd/config_test.go: Updated tests to use the newNewCmdConfigfunction and simplified test cases.cmd/generate_test.go: Adjusted tests to use the newNewCmdGeneratefunction.cmd/openapi_spec_test.go: Updated tests to use the newNewCmdOpenAPISpecfunction, removed mock client setup, and simplified test case structure. [1] [2] [3]
-
Root Command Update:
cmd/root.go: IntroducedNewCmdRootfunction to create the root command, replacing the previousvar rootCmd.
