figured out how to use keywords to create files
This commit is contained in:
		
							parent
							
								
									ae2b6ae9a8
								
							
						
					
					
						commit
						7cdd820138
					
				
							
								
								
									
										31
									
								
								rodo.rkt
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								rodo.rkt
									
									
									
									
									
								
							| @ -5,16 +5,22 @@ | |||||||
|   (displayln (hash-ref hash-list key))) |   (displayln (hash-ref hash-list key))) | ||||||
| 
 | 
 | ||||||
| (define message (hash  | (define message (hash  | ||||||
|                   'incorrect-usage-msg "For usage type `rodo -h` or `rodo --help`" |                  'incorrect-usage-msg "For usage type `rodo -h` or `rodo --help`" | ||||||
|                   'file-not-found "rodo has not been setup in your home directory\nWould you like to set it up now? [y/n]" |                  'file-not-found "rodo has not been setup in your home directory\nWould you like to set it up now? [y/n]" | ||||||
|                   'file-exists ".rodo file exists" |                  'file-exists ".rodo file exists" | ||||||
|                   'item-added "Item added" |                  'item-added "Item added" | ||||||
|                   'item-removed "Item removed" |                  'item-removed "Item removed" | ||||||
|                   'initializing "Initializing rodo in your home directory")) |                  'initializing "Initializing rodo in your home directory")) | ||||||
| 
 | 
 | ||||||
| (define y-n (hash | (define y-n (hash | ||||||
|               'yes '("yes" "Yes" "y" "Y") |              'yes '("yes" "Yes" "y" "Y") | ||||||
|               'no '("no" "No" "n" "N"))) |              'no '("no" "No" "n" "N"))) | ||||||
|  | 
 | ||||||
|  | (define (open/create-file path) | ||||||
|  |   (let ([path (expand-user-path path)]) | ||||||
|  |     (open-output-file path | ||||||
|  |                       #:mode 'text | ||||||
|  |                       #:exists 'can-update))) | ||||||
| 
 | 
 | ||||||
| ; just figuring out stuff here | ; just figuring out stuff here | ||||||
| (define (prompt-user prompt-message) | (define (prompt-user prompt-message) | ||||||
| @ -22,15 +28,16 @@ | |||||||
|   (let ([user-input (read-line)]) |   (let ([user-input (read-line)]) | ||||||
|     (cond |     (cond | ||||||
|       [(member user-input (hash-ref y-n 'yes))   |       [(member user-input (hash-ref y-n 'yes))   | ||||||
|        (displayln "You chose yes")] |        (displayln "You chose yes") | ||||||
|  |        (open/create-file "~/.rodo")] | ||||||
|       [(member user-input (hash-ref y-n 'no))   |       [(member user-input (hash-ref y-n 'no))   | ||||||
|        (displayln "You chose no")] |        (displayln "You chose no")] | ||||||
|       [else  |       [else  | ||||||
|         (displayln "you chose something else")]))) |        (displayln "you chose something else")]))) | ||||||
| 
 | 
 | ||||||
| (define (todo-list-exist?) | (define (todo-list-exist?) | ||||||
|   (if (file-exists? (expand-user-path "~/.rodo")) |   (if (file-exists? (expand-user-path "~/.rodo")) | ||||||
|     (display-hash message 'file-exists) |       (display-hash message 'file-exists) | ||||||
|     (prompt-user 'file-not-found))) |       (prompt-user 'file-not-found))) | ||||||
| 
 | 
 | ||||||
| (todo-list-exist?) | (todo-list-exist?) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user