Skip to content

Commit

Permalink
Merge pull request #18 from ontodev/subcommand-help
Browse files Browse the repository at this point in the history
Help text for subcommands
  • Loading branch information
jamesaoverton authored Nov 28, 2023
2 parents fd272c7 + 0766eb1 commit f248e20
Showing 1 changed file with 57 additions and 7 deletions.
64 changes: 57 additions & 7 deletions src/ldtab/cli.clj
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,59 @@
"Please refer to the manual page for more information."]
(str/join \newline)))

(defn init-usage []
(->> ["ldtab-init"
""
"Create a new LDTab database."
""
"Usage: ldtab init [options] database"
""
"Options:"
(str/join \newline (map #(str " " (first %) "\t" (second %)) init-options))
""
"Please refer to the manual page for more information."]
(str/join \newline)))

;help message for prefix subcommand
(defn prefix-usage []
(->> ["ldtab-prefix"
""
"Define prefixes to shorten IRIs to CURIEs."
""
"Usage: ldtab prefix [options] database [tsv]"
""
"Options:"
(str/join \newline (map #(str " " (first %) "\t" (second %) (if (= (count %) 3) (str "\t" (nth % 2)) "")) prefix-options))
""
"Please refer to the manual page for more information."]
(str/join \newline)))

(defn import-usage []
(->> ["ldtab-import"
""
"Import an RDFXML file into the database."
""
"Usage: ldtab import [options] database ontology"
""
"Options:"
(str/join \newline (map #(str " " (first %) "\t" (second %) (if (= (count %) 3) (str "\t" (nth % 2)) "")) import-options))
""
"Please refer to the manual page for more information."]
(str/join \newline)))

(defn export-usage []
(->> ["ldtab-export"
""
"Export an LDTab database to TTL or TSV."
""
"Usage: ldtab export [options] database output"
""
"Options:"
(str/join \newline (map #(str " " (first %) "\t" (second %) (if (= (count %) 3) (str "\t" (nth % 2)) "")) export-options))
""
"Please refer to the manual page for more information."]
(str/join \newline)))

(defn error-msg [errors]
(str "The following errors occurred while parsing your command:\n\n"
(str/join \newline errors)))
Expand All @@ -78,7 +131,7 @@
(let [{:keys [options arguments errors summary]} (parse-opts command init-options)]
(cond
(:help options)
{:exit-message (usage summary) :ok? true}
{:exit-message (init-usage) :ok? true}

errors
{:exit-message (error-msg errors)}
Expand All @@ -95,7 +148,7 @@
(let [{:keys [options arguments errors summary]} (parse-opts command prefix-options)]
(cond
(:help options)
{:exit-message (usage summary) :ok? true}
{:exit-message (prefix-usage) :ok? true}

(and (:list options)
(not= 2 (count arguments)))
Expand Down Expand Up @@ -123,7 +176,7 @@
(let [{:keys [options arguments errors summary]} (parse-opts command import-options)]
(cond
(:help options)
{:exit-message (usage summary) :ok? true}
{:exit-message (import-usage) :ok? true}

errors
{:exit-message (error-msg errors)}
Expand All @@ -143,7 +196,7 @@
(let [{:keys [options arguments errors summary]} (parse-opts command export-options)]
(cond
(:help options)
{:exit-message (usage summary) :ok? true}
{:exit-message (export-usage) :ok? true}

errors
{:exit-message (error-msg errors)}
Expand Down Expand Up @@ -193,9 +246,6 @@
(System/exit status))


;TODO handle options for subcommand


(defn ldtab-init
[command]
(let [{:keys [options arguments errors summary]} (parse-opts command import-options)
Expand Down

0 comments on commit f248e20

Please sign in to comment.