feat(cli): added command to show detailed repo info
	
		
			
	
		
	
	
		
			
				
	
				ci/woodpecker/push/arch unknown status
				
					Details
				
			
		
			
				
	
				ci/woodpecker/push/deploy unknown status
				
					Details
				
			
		
			
				
	
				ci/woodpecker/push/docker unknown status
				
					Details
				
			
		
			
				
	
				ci/woodpecker/push/build_experimental Pipeline failed
				
					Details
				
			
		
			
				
	
				ci/woodpecker/push/docs Pipeline was successful
				
					Details
				
			
		
			
				
	
				ci/woodpecker/push/lint Pipeline was successful
				
					Details
				
			
		
			
				
	
				ci/woodpecker/push/build Pipeline was successful
				
					Details
				
			
		
			
				
	
				ci/woodpecker/push/test Pipeline was successful
				
					Details
				
			
		
	
				
					
				
			
				
	
				ci/woodpecker/push/arch unknown status
				
					Details
				
			
		
			
				
	
				ci/woodpecker/push/deploy unknown status
				
					Details
				
			
		
			
				
	
				ci/woodpecker/push/docker unknown status
				
					Details
				
			
		
			
				
	
				ci/woodpecker/push/build_experimental Pipeline failed
				
					Details
				
			
		
			
				
	
				ci/woodpecker/push/docs Pipeline was successful
				
					Details
				
			
		
			
				
	
				ci/woodpecker/push/lint Pipeline was successful
				
					Details
				
			
		
			
				
	
				ci/woodpecker/push/build Pipeline was successful
				
					Details
				
			
		
			
				
	
				ci/woodpecker/push/test Pipeline was successful
				
					Details
				
			
		
	
							parent
							
								
									92b8f1fb93
								
							
						
					
					
						commit
						d313c5b786
					
				|  | @ -49,6 +49,18 @@ pub fn cmd() cli.Command { | ||||||
| 					remove(conf, cmd.args[0]) ? | 					remove(conf, cmd.args[0]) ? | ||||||
| 				} | 				} | ||||||
| 			}, | 			}, | ||||||
|  | 			cli.Command{ | ||||||
|  | 				name: 'info' | ||||||
|  | 				required_args: 1 | ||||||
|  | 				usage: 'id' | ||||||
|  | 				description: 'Show detailed information for the repo matching the ID prefix.' | ||||||
|  | 				execute: fn (cmd cli.Command) ? { | ||||||
|  | 					config_file := cmd.flags.get_string('config-file') ? | ||||||
|  | 					conf := env.load<Config>(config_file) ? | ||||||
|  | 
 | ||||||
|  | 					info(conf, cmd.args[0]) ? | ||||||
|  | 				} | ||||||
|  | 			}, | ||||||
| 			cli.Command{ | 			cli.Command{ | ||||||
| 				name: 'edit' | 				name: 'edit' | ||||||
| 				required_args: 1 | 				required_args: 1 | ||||||
|  | @ -102,16 +114,16 @@ pub fn cmd() cli.Command { | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // get_repo_id_by_prefix tries to find the repo with the given prefix in its | // get_repo_by_prefix tries to find the repo with the given prefix in its | ||||||
| // ID. If multiple or none are found, an error is raised. | // ID. If multiple or none are found, an error is raised. | ||||||
| fn get_repo_id_by_prefix(conf Config, id_prefix string) ?string { | fn get_repo_by_prefix(conf Config, id_prefix string) ?(string, GitRepo) { | ||||||
| 	repos := get_repos(conf.address, conf.api_key) ? | 	repos := get_repos(conf.address, conf.api_key) ? | ||||||
| 
 | 
 | ||||||
| 	mut res := []string{} | 	mut res := map[string]GitRepo{} | ||||||
| 
 | 
 | ||||||
| 	for id, _ in repos { | 	for id, repo in repos { | ||||||
| 		if id.starts_with(id_prefix) { | 		if id.starts_with(id_prefix) { | ||||||
| 			res << id | 			res[id] = repo | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -123,7 +135,7 @@ fn get_repo_id_by_prefix(conf Config, id_prefix string) ?string { | ||||||
| 		return error('Multiple repos found for given prefix.') | 		return error('Multiple repos found for given prefix.') | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return res[0] | 	return res.keys()[0], res[res.keys()[0]] | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // list prints out a list of all repositories. | // list prints out a list of all repositories. | ||||||
|  | @ -131,7 +143,7 @@ fn list(conf Config) ? { | ||||||
| 	repos := get_repos(conf.address, conf.api_key) ? | 	repos := get_repos(conf.address, conf.api_key) ? | ||||||
| 
 | 
 | ||||||
| 	for id, details in repos { | 	for id, details in repos { | ||||||
| 		println('${id[..8]}\t$details.url\t$details.branch\t$details.repo\t$details.arch\t$details.schedule') | 		println('${id[..8]}\t$details.url\t$details.branch\t$details.repo') | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -144,7 +156,7 @@ fn add(conf Config, url string, branch string, repo string) ? { | ||||||
| 
 | 
 | ||||||
| // remove removes a repository from the server's list. | // remove removes a repository from the server's list. | ||||||
| fn remove(conf Config, id_prefix string) ? { | fn remove(conf Config, id_prefix string) ? { | ||||||
| 	id := get_repo_id_by_prefix(conf, id_prefix) ? | 	id, _ := get_repo_by_prefix(conf, id_prefix) ? | ||||||
| 	res := remove_repo(conf.address, conf.api_key, id) ? | 	res := remove_repo(conf.address, conf.api_key, id) ? | ||||||
| 
 | 
 | ||||||
| 	println(res.message) | 	println(res.message) | ||||||
|  | @ -160,8 +172,20 @@ fn patch(conf Config, id_prefix string, params map[string]string) ? { | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	id := get_repo_id_by_prefix(conf, id_prefix) ? | 	id, _ := get_repo_by_prefix(conf, id_prefix) ? | ||||||
| 	res := patch_repo(conf.address, conf.api_key, id, params) ? | 	res := patch_repo(conf.address, conf.api_key, id, params) ? | ||||||
| 
 | 
 | ||||||
| 	println(res.message) | 	println(res.message) | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | // info shows detailed information for a given repo. | ||||||
|  | fn info(conf Config, id_prefix string) ? { | ||||||
|  | 	id, repo := get_repo_by_prefix(conf, id_prefix) ? | ||||||
|  | 
 | ||||||
|  | 	println('id: $id') | ||||||
|  | 
 | ||||||
|  | 	$for field in GitRepo.fields { | ||||||
|  | 		val := repo.$(field.name) | ||||||
|  | 		println('$field.name: $val') | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue