Skip to content

Conversation

henilp105
Copy link
Member

@henilp105 henilp105 commented Jun 22, 2024

This PR intends to add the search and discovery of fpm installed and fpm - registry packages directly from cli. this command supports globbing for package name, version, license, namespace. the similar functionality has been patched at the registry repo. (fortran-lang/registry#81). paging is not used in local registry due to multiple search queries.

This is the syntax of the new fpm search functionality:

fpm search --query q* --page 1 --registry URL --namespace n* --package p* --package_version v* --license l* --limit 10 --sort-by [name] --sort [asc/desc]

Parameters:

  • query: Searches in fpm.toml description and fpm-registry descriptions only for fpm-registry (README.md) (case insensitive, globbing supported).
  • package: Searches by package name (case insensitive, globbing supported).
  • registry: Custom registry URL (default: fpm-registry).
  • namespace: Searches by namespace (globbing supported).
  • package_version: Searches by package version (globbing supported).
  • license: Searches by license (globbing supported).
  • page: Page number (default: 1).
  • limit: Number of results (default: 10).
  • sort-by: Sorts by name, author, createdat, updatedat, downloads (default: name).
  • sort: Order of sorting, asc or desc (default: asc).

Tasks left

  • add docs and tests
  • clean and refactor

Thanks and Regards,
Henil

CC @certik @awvwgk @perazz @arteevraina

@henilp105 henilp105 requested a review from perazz June 23, 2024 05:50
' --license License type to filter results.', &
' --limit Maximum number of results to return.', &
' --sort-by Field to sort results by (e.g., name).', &
' --sort Sort order (asc for ascending, desc for descending).', &
Copy link
Member

@perazz perazz Jun 24, 2024

Choose a reason for hiding this comment

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

It would be extremely beneficial to add a few examples of search commands that can be used to search for packages. That gives the reader a better idea of what the command can do, how it works, and how it is integrated with either a local registry or the online registry.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will add some sample queries for each parameter so that it is easy to refer.

@perazz perazz mentioned this pull request Jul 22, 2024
2 tasks
@perazz
Copy link
Member

perazz commented Sep 9, 2024

Let's get this merged @henilp105, is there any more tasks you plan of adding?

@henilp105
Copy link
Member Author

Sure @perazz , Let's get this merged in a week, I will add some tests and clean UI by then.

@henilp105 henilp105 requested a review from Copilot September 29, 2025 05:57
Copy link
Contributor

@Copilot 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 adds a new fpm search command that enables searching for packages in both local registries and the fpm-registry. Users can search using various filters including query text, package name, namespace, version, and license with support for globbing patterns.

  • Adds comprehensive search functionality with multiple filter options and sorting capabilities
  • Integrates search command into the existing fpm CLI structure with help documentation
  • Updates downloader module to properly quote URLs in curl/wget commands

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
test/help_test/help_test.f90 Adds 'search' command to help test suite
src/fpm_command_line.f90 Implements search command line parsing, help text, and settings structure
src/fpm/downloader.f90 Adds quotes around URLs in curl/wget commands for better URL handling
src/fpm/cmd/search.f90 New module implementing the core search functionality for local and remote registries
app/main.f90 Integrates search command into main application dispatcher
Comments suppressed due to low confidence (1)

src/fpm_command_line.f90:1

  • Typo in help text: 'fmp-registry' should be 'fpm-registry'.
!># Definition of the command line interface

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


!> Settings for searching for packages in local and remote registries
type, extends(fpm_cmd_settings) :: fpm_search_settings
character(len=:),allocatable :: query !> search for packages with a specific query (globbing supported)
Copy link
Preview

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

There's a trailing space at the end of the comment line.

Suggested change
character(len=:),allocatable :: query !> search for packages with a specific query (globbing supported)
character(len=:),allocatable :: query !>search for packages with a specific query (globbing supported)

Copilot uses AI. Check for mistakes.

if (namespace==' ') namespace='*'
if (package_version==' ') package_version='*'
if (.not. registry=='') then
print *, 'Using custom registry for seaching packages: ', registry
Copy link
Preview

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

Typo in the print statement: 'seaching' should be 'searching'.

Suggested change
print *, 'Using custom registry for seaching packages: ', registry
print *, 'Using custom registry for searching packages: ', registry

Copilot uses AI. Check for mistakes.

' + install Install project. ', &
' + clean Delete directories in the "build/" directory, except ', &
' dependencies. Prompts for confirmation to delete. ', &
' + search Search for packages in local and fpm-registry ', &
Copy link
Preview

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

Missing article in help text: should be 'local registry and fpm-registry' or 'local and remote registries'.

Suggested change
' + search Search for packages in local and fpm-registry ', &
' + search Search for packages in the local registry and fpm-registry', &

Copilot uses AI. Check for mistakes.

'' ]
help_search=[character(len=80) :: &
'NAME', &
' search(1) - search for the package in local and fpm - registry.', &
Copy link
Preview

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

Inconsistent spacing and grammar: should be 'search for packages in local registry and fpm-registry' (no spaces around hyphen).

Suggested change
' search(1) - search for the package in local and fpm - registry.', &
' search(1) - search for the package in local and fpm-registry.', &

Copilot uses AI. Check for mistakes.

Comment on lines +2 to +3
!> The package can be searched by packagename, namespace, query (description and README.md), and license from the registries (local and remote).
!> the remote registry URL can also be specified by the paramter --registry.
Copy link
Preview

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

Multiple issues: 'packagename' should be 'package name', 'paramter' should be 'parameter', and the second line should start with a capital letter.

Suggested change
!> The package can be searched by packagename, namespace, query (description and README.md), and license from the registries (local and remote).
!> the remote registry URL can also be specified by the paramter --registry.
!> The package can be searched by package name, namespace, query (description and README.md), and license from the registries (local and remote).
!> The remote registry URL can also be specified by the parameter --registry.

Copilot uses AI. Check for mistakes.

if (json%has_key("packages")) then
call get_value(json, 'packages', array)
print *
print '(A,I0,A)', ' Found ', len(array), ' packages in fpm - registry:'
Copy link
Preview

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

Inconsistent spacing: should be 'fpm-registry' (no spaces around hyphen).

Suggested change
print '(A,I0,A)', ' Found ', len(array), ' packages in fpm - registry:'
print '(A,I0,A)', ' Found ', len(array), ' packages in fpm-registry:'

Copilot uses AI. Check for mistakes.

use fpm_downloader, only: downloader_t
use fpm_strings, only: string_t, string_array_contains, split, str,glob
use fpm, only: build_model
use fpm_error, only : error_t, fatal_error, fpm_stop
Copy link
Preview

Copilot AI Sep 29, 2025

Choose a reason for hiding this comment

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

Duplicate import of fpm_error module. The module is already imported on line 9 with error_t and fpm_stop. Consider consolidating these imports.

Copilot uses AI. Check for mistakes.

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