Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(ns bltool.data.default
(:require [bltool.flags :refer :all])
(:require [clojure.core.typed :as t :refer :all])
(:require [slingshot.slingshot :refer [throw+]])
)
(register-flags ["--from"
"What type of data source to read the games/edits from. Use '--help formats' for a list of formats."]
["--to"
"What type of destination to write the changes to. Use '--help formats' for a list of formats."])
(defalias BLGame '{:id String :name String :platform String :progress String})
(defalias BLGameList (Vec BLGame))
(ann ^:no-check slingshot.support/stack-trace [Any * -> Any])
(ann ^:no-check slingshot.support/throw-context [Any * -> Nothing])
(ann read-games [String Any -> BLGameList])
(ann write-games [String BLGameList Any -> Nothing])
(defmulti read-games (fn [fmt source] fmt))
(defmulti write-games (fn [fmt games sink] fmt))
(defmethod read-games :default [fmt source]
(throw+ (str "No support for reading from '" fmt "'. Use '--help fmts' to list available fmts.")))
(defmethod read-games nil [fmt source]
(throw+ "No data source specified. Use '--from <fmt>' to specify a source fmt."))
(defmethod write-games :default [fmt games sink]
(throw+ (str "No support for writing to '" fmt "'. Use '--help fmts' to list available fmts.")))
(defmethod write-games nil [fmt games sink]
(throw+ "No data destination specified. Use '--to <fmt>' to specify a destination fmt."))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.