@@ -14,7 +14,7 @@ use uv_configuration::{
1414 ConfigSettingEntry , ExportFormat , IndexStrategy , KeyringProviderType , PackageNameSpecifier ,
1515 TargetTriple , TrustedHost , TrustedPublishing , VersionControlSystem ,
1616} ;
17- use uv_distribution_types:: { Index , IndexUrl , Origin } ;
17+ use uv_distribution_types:: { Index , IndexUrl , Origin , PipExtraIndex , PipFindLinks , PipIndex } ;
1818use uv_normalize:: { ExtraName , PackageName } ;
1919use uv_pep508:: Requirement ;
2020use uv_pypi_types:: VerbatimParsedUrl ;
@@ -772,48 +772,54 @@ impl<T> Maybe<T> {
772772 }
773773}
774774
775- /// Parse an `--index-url` argument into an [`Index `], mapping the empty string to `None`.
776- fn parse_index_url ( input : & str ) -> Result < Maybe < Index > , String > {
775+ /// Parse an `--index-url` argument into an [`PipIndex `], mapping the empty string to `None`.
776+ fn parse_index_url ( input : & str ) -> Result < Maybe < PipIndex > , String > {
777777 if input. is_empty ( ) {
778778 Ok ( Maybe :: None )
779779 } else {
780- match IndexUrl :: from_str ( input) . map ( Index :: from_index_url) {
781- Ok ( index) => Ok ( Maybe :: Some ( Index {
780+ IndexUrl :: from_str ( input)
781+ . map ( Index :: from_index_url)
782+ . map ( |index| Index {
782783 origin : Some ( Origin :: Cli ) ,
783784 ..index
784- } ) ) ,
785- Err ( err) => Err ( err. to_string ( ) ) ,
786- }
785+ } )
786+ . map ( PipIndex :: from)
787+ . map ( Maybe :: Some )
788+ . map_err ( |err| err. to_string ( ) )
787789 }
788790}
789791
790- /// Parse an `--extra-index-url` argument into an [`Index `], mapping the empty string to `None`.
791- fn parse_extra_index_url ( input : & str ) -> Result < Maybe < Index > , String > {
792+ /// Parse an `--extra-index-url` argument into an [`PipExtraIndex `], mapping the empty string to `None`.
793+ fn parse_extra_index_url ( input : & str ) -> Result < Maybe < PipExtraIndex > , String > {
792794 if input. is_empty ( ) {
793795 Ok ( Maybe :: None )
794796 } else {
795- match IndexUrl :: from_str ( input) . map ( Index :: from_extra_index_url) {
796- Ok ( index) => Ok ( Maybe :: Some ( Index {
797+ IndexUrl :: from_str ( input)
798+ . map ( Index :: from_extra_index_url)
799+ . map ( |index| Index {
797800 origin : Some ( Origin :: Cli ) ,
798801 ..index
799- } ) ) ,
800- Err ( err) => Err ( err. to_string ( ) ) ,
801- }
802+ } )
803+ . map ( PipExtraIndex :: from)
804+ . map ( Maybe :: Some )
805+ . map_err ( |err| err. to_string ( ) )
802806 }
803807}
804808
805- /// Parse a `--find-links` argument into an [`Index `], mapping the empty string to `None`.
806- fn parse_find_links ( input : & str ) -> Result < Maybe < Index > , String > {
809+ /// Parse a `--find-links` argument into an [`PipFindLinks `], mapping the empty string to `None`.
810+ fn parse_find_links ( input : & str ) -> Result < Maybe < PipFindLinks > , String > {
807811 if input. is_empty ( ) {
808812 Ok ( Maybe :: None )
809813 } else {
810- match IndexUrl :: from_str ( input) . map ( Index :: from_find_links) {
811- Ok ( index) => Ok ( Maybe :: Some ( Index {
814+ IndexUrl :: from_str ( input)
815+ . map ( Index :: from_find_links)
816+ . map ( |index| Index {
812817 origin : Some ( Origin :: Cli ) ,
813818 ..index
814- } ) ) ,
815- Err ( err) => Err ( err. to_string ( ) ) ,
816- }
819+ } )
820+ . map ( PipFindLinks :: from)
821+ . map ( Maybe :: Some )
822+ . map_err ( |err| err. to_string ( ) )
817823 }
818824}
819825
@@ -3800,7 +3806,7 @@ pub struct IndexArgs {
38003806 /// The index given by this flag is given lower priority than all other
38013807 /// indexes specified via the `--extra-index-url` flag.
38023808 #[ arg( long, short, env = "UV_INDEX_URL" , value_parser = parse_index_url, help_heading = "Index options" ) ]
3803- pub index_url : Option < Maybe < Index > > ,
3809+ pub index_url : Option < Maybe < PipIndex > > ,
38043810
38053811 /// (Deprecated: use `--index` instead) Extra URLs of package indexes to use, in addition to `--index-url`.
38063812 ///
@@ -3811,7 +3817,7 @@ pub struct IndexArgs {
38113817 /// `--index-url` (which defaults to PyPI). When multiple `--extra-index-url` flags are
38123818 /// provided, earlier values take priority.
38133819 #[ arg( long, env = "UV_EXTRA_INDEX_URL" , value_delimiter = ' ' , value_parser = parse_extra_index_url, help_heading = "Index options" ) ]
3814- pub extra_index_url : Option < Vec < Maybe < Index > > > ,
3820+ pub extra_index_url : Option < Vec < Maybe < PipExtraIndex > > > ,
38153821
38163822 /// Locations to search for candidate distributions, in addition to those found in the registry
38173823 /// indexes.
@@ -3822,7 +3828,7 @@ pub struct IndexArgs {
38223828 /// If a URL, the page must contain a flat list of links to package files adhering to the
38233829 /// formats described above.
38243830 #[ arg( long, short, value_parser = parse_find_links, help_heading = "Index options" ) ]
3825- pub find_links : Option < Vec < Maybe < Index > > > ,
3831+ pub find_links : Option < Vec < Maybe < PipFindLinks > > > ,
38263832
38273833 /// Ignore the registry index (e.g., PyPI), instead relying on direct URL dependencies and those
38283834 /// provided via `--find-links`.
0 commit comments