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

feat: Add search-jobs CLI commands for managing search jobs #1145

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

trly
Copy link

@trly trly commented Feb 18, 2025

Add new src search-jobs command with subcommands to manage search jobs:

  • create: Create new search jobs with query validation
  • get: Retrieve search job details by ID
  • list: List search jobs with sorting and pagination
  • cancel: Cancel running search jobs
  • delete: Remove search jobs

The command provides functionality to:

  • Format output using Go templates
  • Sort and filter search jobs
  • Track job status

Test plan

Automated tests

Command registration tests

Verifies proper registration of the main search-jobs command
Validates command aliases
Ensures all subcommands (cancel, create, delete, get, list) are registered

Individual command tests:

Test retrieving job details

Handles existing jobs, non-existent jobs, empty IDs
Tests various output formatting options

Test job creation

Validates query parameters
Tests successful job creation flow
Includes query validation before creation

Test listing jobs

Handles pagination limits
Supports sorting options (asc/desc)
Validates order-by parameters

Test job cancellation

Handles running vs completed jobs
Tests non-existent job scenarios

Test job deletion

Tests successful deletion flows
Handles non-existent jobs

Manual testing

Tested all new command functionality locally to ensure UX and functionality matched the new feature documentation.

Add new `src search-jobs` command with subcommands to manage search jobs:
- create: Create new search jobs with query validation
- get: Retrieve search job details by ID
- list: List search jobs with sorting and pagination
- cancel: Cancel running search jobs
- delete: Remove search jobs

The command provides functionality to:
- Format output using Go templates
- Sort and filter search jobs
- Track job status
@trly trly requested a review from a team as a code owner February 18, 2025 19:05
@trly
Copy link
Author

trly commented Feb 18, 2025

I'm also working on sourcegraph-docs updates for this, how are those normally synced to release when a new cli-version is released?

@trly
Copy link
Author

trly commented Feb 18, 2025

This is also my first foray into Go. I'm pretty certain that the tests i generated/built aren't necessarily testing the CLI functionality directly, but rather just mocking request/responses to the mock API. If these aren't necessarily correct or needed, I'm happy to remove them :)

@peterguy
Copy link
Contributor

What do you think about adding logs and download sub-commands?

Downloading the log file or the output file doesn't use the GQL API - it's just $SRC_ENDPOINT/.api/search/export/<id>.log or .jsonl, but might be nice to include as a sub command so the user doesn't have to separately automate a curl call to grab the logs or output.

@trly
Copy link
Author

trly commented Feb 18, 2025

I can definitely add those. I was debating between that or just leaving it to the user utilizing to tool to make use of the JSON response. Having the sub-command will definitely make it easier for users that aren't integrating with an external tool.

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.

2 participants