From a0ef0d48e06716b0bb9f7318e62d0368e4e8fd55 Mon Sep 17 00:00:00 2001 From: gered Date: Wed, 29 Jun 2016 09:48:44 -0400 Subject: [PATCH] fix up formatting in cli usage summary --- src/mtgcoll/cli.clj | 6 ++++-- src/mtgcoll/utils.clj | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/mtgcoll/cli.clj b/src/mtgcoll/cli.clj index c4dd144..06d41a3 100644 --- a/src/mtgcoll/cli.clj +++ b/src/mtgcoll/cli.clj @@ -1,7 +1,9 @@ (ns mtgcoll.cli (:require [clojure.string :as string] - [clojure.tools.cli :as cli])) + [clojure.tools.cli :as cli]) + (:use + mtgcoll.utils)) (def ^:private cli-options [["-c" "--config EDN-CONFIG-FILE" @@ -18,7 +20,7 @@ (defn- ->actions-summary [] (->> actions - (map (fn [[action desc]] (str " " action "\t\t" desc))) + (map (fn [[action desc]] (str " " (pad-string 20 action) " " desc))) (string/join \newline))) (defn- ->usage-string diff --git a/src/mtgcoll/utils.clj b/src/mtgcoll/utils.clj index 22d0299..e744f99 100644 --- a/src/mtgcoll/utils.clj +++ b/src/mtgcoll/utils.clj @@ -50,3 +50,10 @@ body (:body response)] (if-not (empty? body) body))) + +(defn pad-string + [n s & [c]] + (let [c (or c \space)] + (if (< (count s) n) + (->> (repeat c) (concat s) (take n) (string/join)) + s)))