支持export指令
This commit is contained in:
		
							
								
								
									
										53
									
								
								export.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								export.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,53 @@ | |||||||
|  | // Package command ... | ||||||
|  | // | ||||||
|  | // Description : command ... | ||||||
|  | // | ||||||
|  | // Author : go_developer@163.com<白茶清欢> | ||||||
|  | // | ||||||
|  | // Date : 2022-05-22 20:34 | ||||||
|  | package command | ||||||
|  |  | ||||||
|  | import ( | ||||||
|  | 	"fmt" | ||||||
|  |  | ||||||
|  | 	"git.zhangdeman.cn/zhangdeman/command/define" | ||||||
|  | ) | ||||||
|  |  | ||||||
|  | // Export 导入环境变量 | ||||||
|  | // | ||||||
|  | // Author : go_developer@163.com<白茶清欢> | ||||||
|  | // | ||||||
|  | // Date : 20:35 2022/5/22 | ||||||
|  | func Export() *export { | ||||||
|  | 	return &export{} | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // export 命令,导入环境变量 | ||||||
|  | // | ||||||
|  | // Author : go_developer@163.com<白茶清欢> | ||||||
|  | // | ||||||
|  | // Date : 20:34 2022/5/22 | ||||||
|  | type export struct { | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Set 设置环境变量 | ||||||
|  | // | ||||||
|  | // Author : go_developer@163.com<白茶清欢> | ||||||
|  | // | ||||||
|  | // Date : 20:37 2022/5/22 | ||||||
|  | func (e *export) Set(name string, value string) *define.Result { | ||||||
|  | 	return Execute("", "export", []string{fmt.Sprintf("%s=%s", name, value)}) | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // BatchSet 批量设置环境变量 | ||||||
|  | // | ||||||
|  | // Author : go_developer@163.com<白茶清欢> | ||||||
|  | // | ||||||
|  | // Date : 20:44 2022/5/22 | ||||||
|  | func (e *export) BatchSet(data map[string]string) map[string]*define.Result { | ||||||
|  | 	result := make(map[string]*define.Result) | ||||||
|  | 	for name, value := range data { | ||||||
|  | 		result[name] = e.Set(name, value) | ||||||
|  | 	} | ||||||
|  | 	return result | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user