Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

This is a Go-based CLI tool for interacting with JuliaHub, a platform for Julia computing. The CLI provides commands for authentication, dataset management, registry management, project management, user information, token management, Git integration, and Julia integration.

## Architecture
Expand Down
130 changes: 129 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@
Available command categories:
auth - Authentication and token management
dataset - Dataset operations (list, download, upload, status)
package - Package search and exploration
registry - Registry management (list registries)
project - Project management (list, filter by user)
user - User information and profile
Expand Down Expand Up @@ -555,6 +556,121 @@
},
}

var packageCmd = &cobra.Command{
Use: "package",
Short: "Package search commands",
Long: `Search and explore Julia packages on JuliaHub.

Packages are Julia libraries that provide reusable functionality. JuliaHub
hosts packages from multiple registries and provides comprehensive search
capabilities including filtering by tags, installation status, failures, and more.`,
Copy link
Member

Choose a reason for hiding this comment

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

Lets remove installation status and failure since they either dont work or should be removed

}

var packageSearchCmd = &cobra.Command{
Use: "search [search-term]",
Short: "Search for packages",
Long: `Search for Julia packages on JuliaHub.

Displays package information including:
- Package name, owner, and UUID
- Version information
- Description and repository
- Tags and star count
- Installation status
Copy link
Member

Choose a reason for hiding this comment

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

lets remove installation status

- License information

Filtering options:
- Filter by registry using --registries flag (searches all registries by default)
- Filter by installation status (--installed, --not-installed)
Copy link
Member

Choose a reason for hiding this comment

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

As mentioned above lets remove these

- Filter by packages with download failures (--has-failures)

Use --verbose flag for comprehensive output, or get a concise summary by default.`,
Example: " jh package search dataframes\n jh package search --installed\n jh package search --verbose plots\n jh package search --limit 20 ml\n jh package search --registries General optimization",
Args: cobra.MaximumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
server, err := getServerFromFlagOrConfig(cmd)
if err != nil {
fmt.Printf("Failed to get server config: %v\n", err)
os.Exit(1)
}

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

limit, _ := cmd.Flags().GetInt("limit")
offset, _ := cmd.Flags().GetInt("offset")
verbose, _ := cmd.Flags().GetBool("verbose")
registryNamesStr, _ := cmd.Flags().GetString("registries")

// Handle boolean flags - only set if explicitly provided
var installed *bool
var notInstalled *bool
var hasFailures *bool

if cmd.Flags().Changed("installed") {
val, _ := cmd.Flags().GetBool("installed")
installed = &val
}

if cmd.Flags().Changed("not-installed") {
val, _ := cmd.Flags().GetBool("not-installed")
notInstalled = &val
}

if cmd.Flags().Changed("has-failures") {
val, _ := cmd.Flags().GetBool("has-failures")
hasFailures = &val
}

// Fetch all registries from the API
allRegistries, err := fetchRegistries(server)
if err != nil {
fmt.Printf("Failed to fetch registries: %v\n", err)
os.Exit(1)
}

// Determine which registry IDs to use
var registryIDs []int
if registryNamesStr != "" {
// Use only specified registries
requestedNames := strings.Split(registryNamesStr, ",")
for _, requestedName := range requestedNames {
requestedName = strings.TrimSpace(requestedName)
if requestedName == "" {
continue
}

// Find matching registry (case-insensitive)
found := false
for _, reg := range allRegistries {
if strings.EqualFold(reg.Name, requestedName) {
registryIDs = append(registryIDs, reg.RegistryID)
found = true
break
}
}

if !found {
fmt.Printf("Registry not found: '%s'\n", requestedName)
os.Exit(1)
}
}
} else {
// Use all registries
for _, reg := range allRegistries {
registryIDs = append(registryIDs, reg.RegistryID)
}
}

if err := searchPackages(server, search, limit, offset, installed, notInstalled, hasFailures, registryIDs, verbose); err != nil {
fmt.Printf("Failed to search packages: %v\n", err)
os.Exit(1)
}
},
}

var registryCmd = &cobra.Command{
Use: "registry",
Short: "Registry management commands",
Expand Down Expand Up @@ -1121,6 +1237,17 @@
datasetUploadCmd.Flags().StringP("server", "s", "juliahub.com", "JuliaHub server")
datasetUploadCmd.Flags().Bool("new", false, "Create a new dataset")
datasetStatusCmd.Flags().StringP("server", "s", "juliahub.com", "JuliaHub server")
<<<<<<< HEAD

Check failure on line 1240 in main.go

View workflow job for this annotation

GitHub Actions / test

syntax error: unexpected <<, expected }
packageSearchCmd.Flags().StringP("server", "s", "juliahub.com", "JuliaHub server")
packageSearchCmd.Flags().Int("limit", 10, "Maximum number of results to return")
packageSearchCmd.Flags().Int("offset", 0, "Number of results to skip")
packageSearchCmd.Flags().Bool("installed", false, "Filter by installed packages")
packageSearchCmd.Flags().Bool("not-installed", false, "Filter by not installed packages")
packageSearchCmd.Flags().Bool("has-failures", false, "Filter by packages with download failures")
packageSearchCmd.Flags().String("registries", "", "Filter by registry names (comma-separated, e.g., 'General,CustomRegistry')")
packageSearchCmd.Flags().Bool("verbose", false, "Show detailed package information")
=======
>>>>>>> 598769ba8b5d9204ddfa0992fd62b572c17226b4
registryListCmd.Flags().StringP("server", "s", "juliahub.com", "JuliaHub server")
registryListCmd.Flags().Bool("verbose", false, "Show detailed registry information")
projectListCmd.Flags().StringP("server", "s", "juliahub.com", "JuliaHub server")
Expand All @@ -1139,6 +1266,7 @@
authCmd.AddCommand(authLoginCmd, authRefreshCmd, authStatusCmd, authEnvCmd)
jobCmd.AddCommand(jobListCmd, jobStartCmd)
datasetCmd.AddCommand(datasetListCmd, datasetDownloadCmd, datasetUploadCmd, datasetStatusCmd)
packageCmd.AddCommand(packageSearchCmd)
registryCmd.AddCommand(registryListCmd)
projectCmd.AddCommand(projectListCmd)
userCmd.AddCommand(userInfoCmd)
Expand All @@ -1149,7 +1277,7 @@
runCmd.AddCommand(runSetupCmd)
gitCredentialCmd.AddCommand(gitCredentialHelperCmd, gitCredentialGetCmd, gitCredentialStoreCmd, gitCredentialEraseCmd, gitCredentialSetupCmd)

rootCmd.AddCommand(authCmd, jobCmd, datasetCmd, projectCmd, registryCmd, userCmd, adminCmd, juliaCmd, cloneCmd, pushCmd, fetchCmd, pullCmd, runCmd, gitCredentialCmd, updateCmd)
rootCmd.AddCommand(authCmd, jobCmd, datasetCmd, projectCmd, packageCmd, registryCmd, userCmd, adminCmd, juliaCmd, cloneCmd, pushCmd, fetchCmd, pullCmd, runCmd, gitCredentialCmd, updateCmd)
}

func main() {
Expand Down
62 changes: 62 additions & 0 deletions package_search.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
query FilteredPackages(
$search: String
$limit: Int
$offset: Int
$matchtags: _text
$registries: _int8
$hasfailures: Boolean
$installed: Boolean
$notinstalled: Boolean
$licenses: _text
$order: [package_rank_vw_order_by!]
$filter: package_rank_vw_bool_exp = {}
) {
package_search(
args: {
search: $search
matchtags: $matchtags
licenses: $licenses
isinstalled: $installed
notinstalled: $notinstalled
hasfailures: $hasfailures
registrylist: $registries
}
order_by: $order
limit: $limit
offset: $offset
where: { _and: [{ fit: { _gte: 1 } }, $filter] }
) {
name
owner
slug
license
isapp
score
registrymap {
version
registryid
status
isapp
isjsml
__typename
}
metadata {
docshosteduri
versions
description
docslink
repo
owner
tags
starcount
__typename
}
uuid
installed
failures {
package_version
__typename
}
__typename
}
}
Loading
Loading