Skip to content

Implement communities, licenses, and access links CLI commands#37

Merged
ran-codes merged 1 commit intomainfrom
issue-12/communities-licenses-access-cli
Feb 17, 2026
Merged

Implement communities, licenses, and access links CLI commands#37
ran-codes merged 1 commit intomainfrom
issue-12/communities-licenses-access-cli

Conversation

@ran-codes
Copy link
Copy Markdown
Owner

ELI5

Now you can browse Zenodo communities ("what groups/organizations exist?"), search licenses ("what license should I pick for my dataset?"), and list share links for a record. These are the last three read-only commands, completing Phase 2's user-facing CLI.

Summary

  • zenodo communities list [query] — search/list Zenodo communities
  • zenodo licenses search [query] — search available licenses
  • zenodo access links list <id> — list share links for a record
  • All respect --output and --fields flags

Code changes

File What
internal/cli/communities.go communities list command
internal/cli/licenses.go licenses search command
internal/cli/access.go access links list command

Test plan

  • go build ./... compiles
  • go test ./... — all 54 tests pass

Closes #12

🤖 Generated with Claude Code

Add user-facing CLI commands for the remaining read operations.

- communities list [query]: search/list communities
- licenses search [query]: search available licenses
- access links list <id>: list share links for a record
- All commands output via Format() respecting --output and --fields

Closes #12

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 17, 2026 19:54
@ran-codes ran-codes merged commit b778340 into main Feb 17, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements the final three read-only CLI commands for Phase 2: communities, licenses, and access links. These commands enable users to browse Zenodo communities, search for appropriate licenses, and view share links for records. All commands follow the established CLI patterns and support the standard --output and --fields flags for flexible output formatting.

Changes:

  • Added zenodo communities list [query] command to search/list Zenodo communities
  • Added zenodo licenses search [query] command to search available licenses
  • Added zenodo access links list <id> command to list share links for a record

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
internal/cli/communities.go Implements communities list command with query parameter support
internal/cli/licenses.go Implements licenses search command with query parameter support
internal/cli/access.go Implements access links list command for viewing record share links

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +34 to +38
result, err := client.SearchCommunities(q, 0, 0)
if err != nil {
return err
}
return output.Format(os.Stdout, result.Hits.Hits, appCtx.Output, appCtx.Fields)
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing pagination feedback to user. Similar to the pattern in records.go (lines 55, 96), this command should print to stderr showing how many results are displayed versus the total available. Add "fmt" to imports and add fmt.Fprintf(os.Stderr, "Showing %d of %d communities\n", len(result.Hits.Hits), result.Hits.Total) before the return statement.

Copilot uses AI. Check for mistakes.
Comment on lines +34 to +38
result, err := client.SearchLicenses(q, 0, 0)
if err != nil {
return err
}
return output.Format(os.Stdout, result.Hits.Hits, appCtx.Output, appCtx.Fields)
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing pagination feedback to user. Similar to the pattern in records.go (lines 55, 96), this command should print to stderr showing how many results are displayed versus the total available. Add "fmt" to imports and add fmt.Fprintf(os.Stderr, "Showing %d of %d licenses\n", len(result.Hits.Hits), result.Hits.Total) before the return statement.

Copilot uses AI. Check for mistakes.
Comment on lines +16 to +40
var communitiesListCmd = &cobra.Command{
Use: "list [query]",
Short: "List or search communities",
Long: `List or search Zenodo communities.

Examples:
zenodo communities list
zenodo communities list "open science"
zenodo communities list --output csv`,
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client := api.NewClient(appCtx.BaseURL, appCtx.Token)

q := ""
if len(args) > 0 {
q = args[0]
}

result, err := client.SearchCommunities(q, 0, 0)
if err != nil {
return err
}
return output.Format(os.Stdout, result.Hits.Hits, appCtx.Output, appCtx.Fields)
},
}
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding an --all flag similar to the records commands (records.go lines 32, 74) to fetch all pages of results. The records commands use api.PaginateAll for this. While communities and licenses would need their own PaginateAll functions (since the current one is specific to RecordSearchResult), this would provide consistency with the records commands and handle cases where results exceed 100 items.

Copilot uses AI. Check for mistakes.
Comment on lines +16 to +40
var licensesSearchCmd = &cobra.Command{
Use: "search [query]",
Short: "Search available licenses",
Long: `Search Zenodo's available licenses.

Examples:
zenodo licenses search
zenodo licenses search "creative commons"
zenodo licenses search "MIT" --output json`,
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
client := api.NewClient(appCtx.BaseURL, appCtx.Token)

q := ""
if len(args) > 0 {
q = args[0]
}

result, err := client.SearchLicenses(q, 0, 0)
if err != nil {
return err
}
return output.Format(os.Stdout, result.Hits.Hits, appCtx.Output, appCtx.Fields)
},
}
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding an --all flag similar to the records commands (records.go lines 32, 74) to fetch all pages of results. The records commands use api.PaginateAll for this. While communities and licenses would need their own PaginateAll functions (since the current one is specific to RecordSearchResult), this would provide consistency with the records commands and handle cases where results exceed 100 items.

Copilot uses AI. Check for mistakes.
@ran-codes ran-codes deleted the issue-12/communities-licenses-access-cli branch February 18, 2026 15:56
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.

Implement communities, licenses, and access links CLI commands

2 participants