@@ -19,7 +19,7 @@ struct Asset {
1919 size : u64 ,
2020}
2121
22- pub async fn handle_download ( features : Option < Vec < String > > ) {
22+ pub async fn handle_download ( tag : Option < String > , features : Option < Vec < String > > ) {
2323 println ! (
2424 "{}" ,
2525 "╔══════════════════════════════════════════════════════════════════════════════╗"
@@ -69,7 +69,7 @@ pub async fn handle_download(features: Option<Vec<String>>) {
6969
7070 // Download the definitions
7171 println ! ( "\n {} Starting download process..." , "📥" . bright_blue( ) ) ;
72- let bytes = match download_definitions_as_bytes ( ) . await {
72+ let bytes = match download_definitions_as_bytes ( tag ) . await {
7373 Some ( bytes) => {
7474 println ! (
7575 "{} {}" ,
@@ -119,9 +119,19 @@ pub async fn handle_download(features: Option<Vec<String>>) {
119119 println ! ( "{}" , "═" . repeat( 80 ) . bright_cyan( ) ) ;
120120}
121121
122- async fn download_definitions_as_bytes ( ) -> Option < bytes:: Bytes > {
122+ async fn download_definitions_as_bytes ( tag : Option < String > ) -> Option < bytes:: Bytes > {
123123 let client = reqwest:: Client :: new ( ) ;
124- let url = "https://api.github.com/repos/code0-tech/code0-definition/releases/latest" ;
124+
125+ let url = match tag {
126+ Some ( t) => {
127+ println ! ( "Selected the version: {}" , t. bright_blue( ) ) ;
128+ format ! ( "https://api.github.com/repos/code0-tech/code0-definition/releases/tags/{t}" )
129+ }
130+ None => {
131+ println ! ( "No version specified, using latest version" ) ;
132+ String :: from ( "https://api.github.com/repos/code0-tech/code0-definition/releases/latest" )
133+ }
134+ } ;
125135
126136 println ! (
127137 "{} Fetching latest release information..." ,
@@ -171,7 +181,7 @@ async fn download_definitions_as_bytes() -> Option<bytes::Bytes> {
171181 println ! (
172182 "{} {}" ,
173183 "✅" . green( ) ,
174- format!( "Found latest release: {}" , release. tag_name) . green( )
184+ format!( "Selected release: {}" , release. tag_name) . green( )
175185 ) ;
176186 release
177187 }
0 commit comments