Skip to content

Commit

Permalink
fix broken import
Browse files Browse the repository at this point in the history
  • Loading branch information
Memorytaco committed Apr 15, 2019
1 parent d35bcc7 commit 16524f9
Show file tree
Hide file tree
Showing 35 changed files with 106 additions and 1,519 deletions.
65 changes: 0 additions & 65 deletions melt/assert.scm

This file was deleted.

24 changes: 0 additions & 24 deletions melt/asset.scm

This file was deleted.

66 changes: 0 additions & 66 deletions melt/command.scm

This file was deleted.

43 changes: 0 additions & 43 deletions melt/command/exec.scm

This file was deleted.

52 changes: 0 additions & 52 deletions melt/command/init.scm

This file was deleted.

58 changes: 36 additions & 22 deletions melt/command/post.scm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
(melt uutil)
(melt lib console)
(melt config)
(melt data)
(melt cell)
(melt command))

(define (post data)
Expand Down Expand Up @@ -32,12 +34,12 @@
(let* ((str-num-sequence (map car (get-md-post-title-list "post")))
(numbers (sort > (map string->number str-num-sequence))))
(if (not (null? title))
(write-template (car title)
(string-append (config-value-query 'post data)
"/"
(number->string (+ 1 (car numbers))) ".md"))
(gemd:error "please provide a title\n")))))

(begin (write-template (car title)
(string-append (data-value-query 'post data)
"/"
(number->string (+ 1 (car numbers))) ".md"))
(gemd:info (string-append "generate new post: " (car title))))
(gemd:error "please provide a title.")))))

(define (write-template title path)
(call-with-output-file
Expand All @@ -52,22 +54,22 @@
;; command list
(define (action-list data)
(lambda args
(if (not (null? args))
(if (equal? (car args) "-h")
(gem:display
(gem:text "[38;5;15m" "A subcommand to list post sequence\n")))
(list-post data))))
(cond
[(null? args)
((list-post data))
(gemd:info "List complete :)")]
[(and (eq? (length args) 1) (equal? (car args) "-h"))
(gemd:help "A subcommand to list post sequence.")])))

(define (list-post data)
(lambda ()
(do ((title-list (sort (lambda (pre aft) (string>? (car pre) (car aft))) (get-md-post-title-list (config-value-query 'post data)))
(do ((title-list (sort (lambda (pre aft) (string>? (car pre) (car aft))) (get-md-post-title-list (data-value-query 'post data)))
(cdr title-list)))
((null? title-list) (gem:display (gem:text "[37m" "=====\n")))
((null? title-list) (gemd:info "command complete."))
(gemd:item (string-append
(gem:text "[38;5;15m" (car (car title-list)))
" ==> "
(gem:text "[38;5;15m" (cdr (car title-list)))
"\n")))))
(gem:text "[38;5;15m" (cdr (car title-list))))))))


;; ====================================================================
Expand All @@ -84,11 +86,23 @@
;; use external shell to call editor
(define (call-editor data)
(lambda (number)
(system (string-append (config-value-query 'editor data)
" "
(config-value-query 'post data)
"/"
number ".md"))))


(define editor (make-cell (data-value-query 'editor data)
(lambda (value) (if value
(begin
(gemd:info (string-append "Got editor: " value))
(editor value (lambda (x) x))
value)
(begin
(gemd:warn "Editor not available")
#f)))))
(gemd:info "invoking external editor ...")
(if (editor)
(begin
(system (string-append (editor)
" "
(data-value-query 'post data)
"/"
number ".md"))
(gemd:info "successfully quit."))
(gemd:help "Please add editor config in your config file."))))
)
23 changes: 5 additions & 18 deletions melt/config.ss
Original file line number Diff line number Diff line change
@@ -1,30 +1,17 @@
(library
(melt config)
(export config-update-option!
config-add-option!
config-value-query
config-options-query)
melt:config-options-query)
(import (scheme)
(melt data))

;; update one option or add the option with default value
(define (config-update-option! key value data)
(let ((para (data-guard-query key data)))
(if para
(para value)
(config-add-option! key value data))))

;; add one option with default value
(define (config-add-option! key value data)
(update-data! (create-data '(key) (list value)) data))

;; return the value of #f if it doesn't exist
(define (config-value-query key data)
(data-value-query key data))
(define (config-update-option! key value data)
(update-data! (create-data (list key) (list value)) data))

;; if no arg provided, return the whole options list
;; if provide a key(option), return #t if exists and #f otherwise
(define (config-options-query data)
;; if provide a key(option), return the value if exists and #f otherwise
(define (melt:config-options-query data)
(lambda para
(cond
[(null? para)
Expand Down
Loading

0 comments on commit 16524f9

Please sign in to comment.