Make colors work!
This commit is contained in:
		
							parent
							
								
									d0c783a421
								
							
						
					
					
						commit
						e8bc9f0655
					
				
							
								
								
									
										39
									
								
								examples
									
									
									
									
									
								
							
							
						
						
									
										39
									
								
								examples
									
									
									
									
									
								
							| @ -5,4 +5,43 @@ | ||||
|   echo Hello, world! | ||||
| } | ||||
| 
 | ||||
| ⚡️build() { | ||||
|   _help-line "Build an incredible script" "$@" | ||||
|   echo "echo hi" > .generated/potato | ||||
|   chmod +x .generated/potato | ||||
| } | ||||
| 
 | ||||
| ⚡️run() { | ||||
|   _help-line "Run the script" "$@" | ||||
|   ⚡️build | ||||
|   .generated/potato "$@" | ||||
| } | ||||
| 
 | ||||
| ⚡️check() { | ||||
|   _help-line "Verify the script passes shellcheck" "$@" | ||||
|   ⚡️build | ||||
|   shellcheck .generated/potato | ||||
| } | ||||
| 
 | ||||
| ⚡️test() { | ||||
|   _help-line "Test output of the script" "$@" | ||||
|   ⚡️build | ||||
|   [ "$(.generated/potato)" == "hi" ] | ||||
| } | ||||
| 
 | ||||
| ⚡️clean() { | ||||
|   _help-line "Delete generated GARBAGE" "$@" | ||||
|   rm -rf .generated | ||||
| } | ||||
| 
 | ||||
| ⚡️good() { | ||||
|   _help-line "Show a nice message for something nice happening" "$@" | ||||
|   _good-message + Good Message | ||||
| } | ||||
| 
 | ||||
| ⚡️bad() { | ||||
|   _help-line "Show a bad message for something bad happening" "$@" | ||||
|   _bad-message - Bad Message | ||||
| } | ||||
| 
 | ||||
| source ⚡️ | ||||
|  | ||||
							
								
								
									
										35
									
								
								test/test-sugar
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								test/test-sugar
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,35 @@ | ||||
| #!/usr/bin/env bash | ||||
| 
 | ||||
| testGoodMessageShouldBeGreen() { | ||||
|   echo ' | ||||
|   #!/usr/bin/env bash | ||||
| 
 | ||||
|   ⚡️hello() { | ||||
|     _good-message "hello" | ||||
|   } | ||||
|   ' > go | ||||
| 
 | ||||
|   echo "source $REPO_ROOT/⚡️" >> go | ||||
|   chmod +x go | ||||
| 
 | ||||
|   try ./go hello | ||||
|   assertEquals "[32mhello[0m" "$STDOUT" | ||||
| } | ||||
| 
 | ||||
| testBadMessageShouldBeRed() { | ||||
|   echo ' | ||||
|   #!/usr/bin/env bash | ||||
| 
 | ||||
|   ⚡️hello() { | ||||
|     _bad-message "hello" | ||||
|   } | ||||
|   ' > go | ||||
| 
 | ||||
|   echo "source $REPO_ROOT/⚡️" >> go | ||||
|   chmod +x go | ||||
| 
 | ||||
|   try ./go hello | ||||
|   assertEquals "[31mhello[0m" "$STDOUT" | ||||
| } | ||||
| 
 | ||||
| source $(dirname $0)/runner | ||||
							
								
								
									
										10
									
								
								⚡️
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								⚡️
									
									
									
									
									
								
							| @ -17,7 +17,7 @@ main() { | ||||
|     if [[ $(type ⚡️$subcommand) =~ _help-line ]]; then | ||||
|       printf "\t%-20s - %s\n" "$subcommand" "$(⚡️$subcommand help-line)" | ||||
|     else | ||||
|       printf "\t%-20s" $subcommand | ||||
|       printf "\t%-20s\n" $subcommand | ||||
|     fi | ||||
|   done | ||||
| } | ||||
| @ -32,4 +32,12 @@ _help-line() { | ||||
|   fi | ||||
| } | ||||
| 
 | ||||
| _good-message() { | ||||
|   echo -e "\e[32m$@\e[0m" | ||||
| } | ||||
| 
 | ||||
| _bad-message() { | ||||
|   echo -e "\e[31m$@\e[0m" | ||||
| } | ||||
| 
 | ||||
| main "$@" | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user