Browse Source

Got this in a working state! Gonna test some things, remove some old comments and possibly start using it!

main
Jesse Laprade 2 months ago
parent
commit
c795209398
1 changed files with 40 additions and 11 deletions
  1. +40
    -11
      wg.fnl

+ 40
- 11
wg.fnl View File

@ -109,12 +109,6 @@
(table.insert seq file)))
seq))
;; ---------------------------------------
;; serve
;; ---------------------------------------
(fn serve []
(os.execute "python3 -m http.server 8000 --directory build/"))
;; ---------------------------------------
;; init
;; ---------------------------------------
@ -142,7 +136,8 @@
(file-write file-index contents-index)
(file-write file-style contents-style)
(file-write file-header contents-header)
(file-write file-footer contents-footer)))
(file-write file-footer contents-footer)
(print "Initialization complete!")))
(fn init/read-input []
(let [input (io.read 1)]
@ -160,7 +155,7 @@
(each [_ file (pairs files-required)]
(when (not (file-exists? file))
(print-format " %s" file)))
(print "Do you want to create them? (y/n)")
(print "Do you want to continue? (y/n)")
(io.write "> ")
(init/read-input))
@ -170,6 +165,38 @@
(init/prompt)
(print "The required directories and files exist.")))
;; ---------------------------------------
;; serve
;; ---------------------------------------
(fn serve []
(os.execute "python3 -m http.server 8000 --directory build/"))
;; ---------------------------------------
;; clean
;; ---------------------------------------
(fn clean/start []
(print "Deleting contents of 'build/' directory...")
(path-delete (.. :build "/*"))
(print "Cleaning complete!"))
(fn clean/prompt []
(print "Cleaning will delete everything in the 'build/' directory.")
(print "Do you want to continue? (y/n)")
(io.write "> ")
(let [input (io.read 1)]
(if (= input :y)
(clean/start)
(print "Cancelled the deletion of the 'build/' directory's contents."))))
(fn clean []
(if (directory-exists? :build)
(if (> (# (directory-contents :build)) 0)
(clean/prompt)
(print "'build/' directory empty. Nothing to clean."))
(do (print "'build/' directory doesn't exist.")
(print "For more information, run the following command:")
(print "wg help"))))
;; ---------------------------------------
;; build
;; ---------------------------------------
@ -214,12 +241,14 @@
(if (= (# (directory-contents :copy)) 0)
(print "No directories or files found in the 'copy/' directory. Skipping...")
(do (print "Copying files in 'copy/' directory...")
(path-copy (.. :copy "/*") :build)))
(path-copy (.. :copy "/*") :build)
(print "Copying complete!")))
;; Convert paths
(if (= (# (directory-contents :convert)) 0)
(print "No directories or files found in the 'convert/' directory. Skipping...")
(do (print "Converting files in 'convert/' directory...")
(build/convert :convert))))
(build/convert :convert)
(print "Conversion complete!"))))
;; ---------------------------------------
;; Arg parsing
@ -229,6 +258,6 @@
[:init nil] (init)
[:build nil] (build)
[:serve nil] (serve)
[:clean] (print "Clean command is still being developed"))) ; (clean))) ;; TODO
[:clean nil] (clean)))
(main arg)

Loading…
Cancel
Save