@@ -19,7 +19,7 @@ struct Asset {
19
19
size : u64 ,
20
20
}
21
21
22
- pub async fn handle_download ( features : Option < Vec < String > > ) {
22
+ pub async fn handle_download ( tag : Option < String > , features : Option < Vec < String > > ) {
23
23
println ! (
24
24
"{}" ,
25
25
"╔══════════════════════════════════════════════════════════════════════════════╗"
@@ -69,7 +69,7 @@ pub async fn handle_download(features: Option<Vec<String>>) {
69
69
70
70
// Download the definitions
71
71
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 {
73
73
Some ( bytes) => {
74
74
println ! (
75
75
"{} {}" ,
@@ -119,9 +119,19 @@ pub async fn handle_download(features: Option<Vec<String>>) {
119
119
println ! ( "{}" , "═" . repeat( 80 ) . bright_cyan( ) ) ;
120
120
}
121
121
122
- async fn download_definitions_as_bytes ( ) -> Option < bytes:: Bytes > {
122
+ async fn download_definitions_as_bytes ( tag : Option < String > ) -> Option < bytes:: Bytes > {
123
123
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
+ } ;
125
135
126
136
println ! (
127
137
"{} Fetching latest release information..." ,
@@ -171,7 +181,7 @@ async fn download_definitions_as_bytes() -> Option<bytes::Bytes> {
171
181
println ! (
172
182
"{} {}" ,
173
183
"✅" . green( ) ,
174
- format!( "Found latest release: {}" , release. tag_name) . green( )
184
+ format!( "Selected release: {}" , release. tag_name) . green( )
175
185
) ;
176
186
release
177
187
}
0 commit comments